/*
* Solution:
* Question: Enter the height of the first cat and the number of cats that work at the end, and ask how many cats do not have to work, and what are the heights and sizes of all cats?
* Just clarify the meaning of the question (set H and M as the two input values, K as the number of generations produced, and N as the number of cats produced for each generation)
* N ^ k = M, H * (1/(N + 1) ^ K = 1;
* K = log (M)/log (N) = log (H)/log (N + 1 );
* N is traversed from 1 until the absolute values of the two equations minus 1e-10 are found.
* Then, the K value can be obtained, and some addition operations can be performed.
*/
# Include
# Include
Int main () {int I, m, n, sum1, sum2, num, tmp, x; while (scanf ("% d", & m, & n) & m & n) {num = 1; while (fabs (log (num)/log (num + 1)-log (n)/log (m)> 1e-10) num ++; x = (int) (log (m)/log (num + 1) + 0.5); sum1 = sum2 = 0; for (I = 0; I