#include using namespace std; using ll = long long; #define rep(i, j) for(int i=0; i < (int)(j); i++) template bool set_min(T &a, const T &b) { return a > b ? a = b, true : false; } const ll INFL = 1LL << 60; template T gcd(T a,T b){ T c=a,d=b,r; do{r=c%d;c=d;d=r;}while(r); return c; } template T lcm(T a,T b){return a*b/gcd(a,b);} class Solver { public: ll trial(ll A, ll B, ll T) { ll mini = INFL; rep(k, 2) { if(k != 0) swap(A, B); rep(i, 10000000) { if(A * i >= T) { set_min(mini, A * i); } else { ll j = (T - A * i) / B; while(A * i + B * j < T) j++; set_min(mini, A * i + B * j); } } } return mini; } bool solve() { ll A, B, T; cin >> A >> B >> T; ll ans = 0; ans += (T / (A * B)) * A * B; T %= A * B; cout << ans + trial(A, B, T) << endl; return 0; } }; int main() { cin.tie(0); ios::sync_with_stdio(false); Solver s; s.solve(); return 0; }