import java.util.*; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); long lcm = getLCM(a, b); long count = lcm / a - 1 + lcm / b; int k = sc.nextInt(); long times = k / count; long mod = k % count; TreeSet set = new TreeSet<>(); for (long i = 1; i * a < lcm; i++) { set.add(i * a); } for (long i = 1; i * b < lcm; i++) { set.add(i * b); } if (mod == 0) { long ans = lcm * times; System.out.println(ans); } else { long ans = lcm * times; for (int i = 1; i < mod; i++) { set.pollFirst(); } ans += set.first(); System.out.println(ans); } } static long getLCM(long a, long b) { return a / getGCD(a, b) * b; } static long getGCD(long a, long b) { if (a % b == 0) { return b; } else { return getGCD(b, a % b); } } }