#include typedef long long ll; using namespace std; template void setmin(T & a, T const & b) { if (b < a) a = b; } int main() { ll a, b, t; cin >> a >> b >> t; ll ans = (t + b-1)/b*b; for (ll i = 0; i <= t and t < ans; i += b) { setmin(ans, i + (t-i + a-1)/a*a); } cout << ans << endl; return 0; }