#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; ll A, B, C, K; bool solve(ll X){ return X-(X/A+X/B-X/C) <= K; } int main(){ cin >> A >> B >> K; C = A*B/gcd(A,B); ll l=0, r=9e18, c; while(r-l>1){ c = (l+r)/2; if (solve(c)) l=c; else r=c; } ll mi=max(1LL, l-5); for (ll X=mi; X<=l; X++){ if (X-(X/A+X/B-X/C) == K && X % A != 0 && X % B != 0){ cout << X << endl; return 0; } } return 0; }