import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines from math import gcd import numpy as np A,B,T = map(int,read().split()) def solve_coprime(A,B,T): # assume (A,B) == 1 if A * B < T: return T # できるので # AB is large. B is large. Bの枚数ごとに何とかする U = 10 ** 5 b = np.arange(U,dtype=np.int64) a = np.maximum(0, (T - b * B + A - 1) // A) x = a * A + b * B assert (x >= T).all() return x.min() def solve(A,B,T): g = gcd(A,B) A //= g; B //= g; T = (T + g - 1) // g return g * solve_coprime(A,B,T) # solve(50,80,120), solve(123,456,1), solve(1234, 1688, 10000) answer = solve(A,B,T) print(answer)