#include using namespace std; typedef long long ll; #define int long long signed main(){ int A, B, T; cin >> A >> B >> T; ll lab = 1LL * A * B / __gcd( A, B ); int r = 1LL * T / lab * lab; T %= lab; if( not ( A >= B ) ) swap( A, B ); int minv = ( int ) 2e9; for( int i = 0; i * A <= T + A - 1; ++i ) minv = min( minv, i * A + ( T - i * A + B - 1 ) / B * B ); cout << r + minv << endl; return 0; }