def lcm(x,y): def gcd(x, y): if y == 0: return x else: return gcd(y,x%y) return (x*y)//gcd(x,y) a,b,k = map(int,input().split()) x = lcm(a,b) ac = x//a bc = x//b s = ac+bc-1 y = k//s z = k%s-1 ans = x*y na,nb = a,0 while z: if na