백준
num, p = map(int, input().split()) nums = [num] while True: ans = 0 for n in str(nums[-1]): ans += int(n) ** p if ans in nums: break nums.append(ans) print(nums.index(ans))