import math def lcm(a,b): return a*b//(math.gcd(a,b)) A,B,K=map(int,input().split()) #Aの個数で2分探索 sita=0 ue=K for i in range(100): this=(sita+ue)//2 x=this x+=(this*A)//B x-=(this*A)//lcm(A,B) if x==K: print(A*this) exit() elif x>K: ue=(sita+ue)//2 else:#xK: kosu=x n=this*A sa=kosu-K if n%B==0: n-=B else: n-=n%B sa-=1 n-=sa*B print(n) exit()