#include using namespace std; typedef long long ll; signed main(){ int A, B, T; cin >> A >> B >> T; ll lab = 1LL * A * B / __gcd( A, B ); int r = max( 0, ( int ) ( T / lab - 1 ) ) * lab; T -= r; 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; }