/*
Geometric Series
computes x = sum(z^k)[k=0..k-1], y = z^(k-1)
*/
void abort() { };
extern void abort();
                                                                                                                                                          
                                                                         
extern int __VERIFIER_nondet_int();
                        
/*@ 
    requires (1);
    ensures ((cond != 0));
@*/
void assume_abort_if_not(int cond) {
  if(!cond) {abort();}
}
/*@ 
    requires ((1 <= cond)) && (cond != 0);
    ensures ((1 <= cond)) && (1);
@*/
void __VERIFIER_assert(int cond) {
    if (!(cond)) {
    ERROR:
        {/*@ assert(0); */;}
    }
    return;
}


int main() {
    int z, k;
    unsigned long long x, y, c;
    z = __VERIFIER_nondet_int();
    assume_abort_if_not(z>=0 && z<=20);
    k = __VERIFIER_nondet_int();
    assume_abort_if_not(k>=0 && k<=20);

    x = 1;
    y = 1;
    c = 1;

/*@
loop invariant ((((z <= 20) && (((((((__int128) z * x) + (((__int128) 18446744073709551615U * z) * y)) + ((unsigned __int128) 18446744073709551615U * x)) + 1) % ((unsigned __int128) 1 << 64)) == 0)) && (0 <= z)));
@*/
    while (1) {
        __VERIFIER_assert(1 + x*z - x - z*y == 0);

        if (!(c < k))
            break;

        c = c + 1;
        x = x * z + 1;
        y = y * z;
    }
    __VERIFIER_assert(1 + x*z - x - z*y == 0);
    return 0;
}