import java.util.Arrays; import java.util.HashSet; import java.util.LinkedList; import java.util.Scanner; import java.util.Set; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); final long A = sc.nextLong(); final long B = sc.nextLong(); final long T = sc.nextLong(); final long max = Math.max(A, B); final long min = Math.min(A, B); Set hash = new HashSet(); long answer = Long.MAX_VALUE; for(long i = (T + max - 1) / max; i >= 0; i--){ long value = i * max; value += Math.max(0, (T - value + min - 1) / min * min); //System.out.println(value); if(hash.contains(value)){ break; }else{ answer = Math.min(answer, value); hash.add(value); } } System.out.println(answer); } }