#!/c/Python34/python # coding: utf-8 def main(): A, B, T = map(int, input().split()) ans = 10**10 if A < B: A, B = B, A i = 0 while A*i <= T and i <= B: dif = T - A*i j = (dif+B-1)//B ans = min(ans, A*i+B*j) i += 1 dif = T - A*i j = (dif+B-1)//B ans = min(ans, A*i+B*j) print(ans) if __name__ == '__main__': main()