local function getgcd(x, y) while 0LL < x do x, y = y % x, x end return y end local a, b, k = io.read("*n", "*n", "*n") a = 1LL * a b = 1LL * b local gcd = getgcd(a, b) local lcm = (a / gcd) * b local min, max = 0LL, 1000000000LL * 1000000001LL while 1LL < max - min do local mid = (min + max) / 2LL local v = mid / a + mid / b - mid / lcm if k <= v then max = mid else min = mid end end max = tostring(max):gsub("LL", "") print(max)