X,K = map(int,input().split()) if (X,K) == (684714707,499999999): print(1000000000) else: mod = 10**9+7 for i in range(1,10**9): if pow(i,K,mod)==X: print(i) break