import sys from collections import deque, Counter input = lambda: sys.stdin.readline().rstrip() ii = lambda: int(input()) mi = lambda: map(int, input().split()) li = lambda: list(mi()) inf = 2 ** 63 - 1 mod = 998244353 a, b, c = mi() f = False for i in range(1, 10 ** 6): now = i now *= a if now - b > 0: now -= b else: pass if now == c: f = True print(i) if not f: print(-1)