b1, b2, b3 = map(int, input().split()) for r in range(-10 ** 6, 10 ** 6): d = b2 - r * b1 if r * b2 + d == b3: print(r * b3 + d) break