#めぐる式二部探索 #参考サイト:https://aotamasaki.hatenablog.com/entry/meguru_bisect import math A,B,K = map(int, input().split()) gclcm = (A * B) // math.gcd(A, B) def is_ok(arg): # 整数を買えればTrueを返す return arg//A+arg//B-arg//gclcm 1): mid = (ok + ng) // 2 if is_ok(mid): ok = mid else: ng = mid return ok print(meguru_bisect(max(A,B)*K, 0)+1)