from sys import stdin, stdout input = lambda: stdin.readline().rstrip() write = stdout.write def main(): B1, B2, B3 = map(int, input().split()) d = 0 while 1: if B1 + d and B2 + d: r1 = (B2 - d) // B1 r2 = (B3 - d) // B2 if r1 == r2: break d += 1 ans = r1 * B3 + d print(ans) main()