import java.util.Scanner; public class Main_yukicoder176 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); int t = sc.nextInt(); int m = (t + b - 1) / b; long l = ((long)t / lcm(a, b) - 1) * lcm(a, b) / b; int min = Integer.MAX_VALUE; for (int i = m; i >= 0 && i >= l; i--) { if (i * b >= t) { min = Math.min(min, i * b); } else { min = Math.min(min, (t - i * b + a - 1) / a * a + i * b); } } System.out.println(min); sc.close(); } private static long lcm(int n, int m) { return (long)n / gcd(n, m) * m; } private static int gcd(int n, int m) { if (m == 0) { return n; } else { return gcd(m, n % m); } } }