#!/usr/bin/env python # -*- coding: utf-8 -*- import math A,B,T = map(int,input().split()) A,B = max(A,B),min(A,B) total = 0 for i in range(math.ceil(T/A))[::-1]: if T - total == 0: break if T-total > T-(i*A+B*math.ceil((T-i*A)/B)) >= 0: total = i*A+B*math.ceil((T-i*A)/B) print(total if total > 0 else B)