#include using namespace std; typedef long long ll; #define rep(i,n) for(ll i=0;i<(ll)(n);i++) #define rep1(i,n) for(ll i=1;i<=(ll)(n);i++) #define LOCAL 1; #ifdef LOCAL #define dbg(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl #else #define dbg(x) true #endif template ostream& operator<< (ostream& out, const vector& v) { out << "["; size_t last = v.size() - 1; for (size_t i = 0; i < v.size(); ++i) { out << v[i]; if (i != last) out << ", "; } out << "]"; return out; } template ostream& operator<< (ostream& out, const pair& p) { out << "[" << p.first << ", " << p.second << "]"; return out; } int main(){ ios::sync_with_stdio(false); cin.tie(0); ll a,b,k; cin >> a >> b >> k; ll ub = LLONG_MAX/2; ll lb = 0; while(ub-lb>1){ ll mid = (ub+lb)/2; ll ca = mid/a; ll cb = mid/b; ll tot = ca + cb - (mid)/(a*b/gcd(a,b)); // dbg(tot),dbg(mid); if(tot<=k) lb=mid; else ub = mid; } lb = max(lb/a*a,lb/b*b); cout << lb << endl; return 0; }