import math A,B,K=map(int,input().split()) C=A*B//math.gcd(A,B) H=A*K L=0 while H-L>1: M=(H+L)//2 n=M//A+M//B-M//C if n