import math p, q = map(int, input().split()) n = int(input()) if((p+q)%2 and math.gcd(p, q)==1): print(1/0) else: print(n)