// Arup Guha
// 1/18/2014
// Solution to 2006 MCPC Problem G: Root of the Problem.

import java.util.*;

public class g {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		int base = stdin.nextInt();
		int root = stdin.nextInt();

		// Go through each case.
		while (base != 0 || root != 0) {

			// Get an approximation.
			int guess = (int)Math.pow(base, 1.0/root);
			int diff = 1000001, ans = -1;

			// Try each neighboring value.
			for (int tryVal = -1; tryVal <=1; tryVal++) {
				if (Math.abs(base - mypow(guess+tryVal, root)) < diff) {
					diff = Math.abs(base - mypow(guess+tryVal, root));
					ans = guess+tryVal;
				}
			}

			// Print solution and get next case.
			System.out.println(ans);
			base = stdin.nextInt();
			root = stdin.nextInt();
		}
	}

	public static int mypow(int b, int e) {
		int a = 1;
		for (int i=0; i<e; i++)
			a = a*b;
		return a;
	}
}