#include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef vectorvs; typedef vectorvi; typedef vectorvvi; typedef vectorvd; typedef pairpii; typedef long long ll; typedef pairpll; typedef vectorvl; #define rrep(i,x,n) for(int i=(x);i<(n);++i) #define rep(i,x) rrep(i,0,(x)) #define fi first #define se second #define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i) #define all(c) (c).begin(),(c).end() #define rall(c) (c).rbegin(),(c).rend() #define pb push_back #define maxs(a,b) (a)=max(a,b) #define mins(a,b) (a)=min(a,b) ll gcd(ll a,ll b){ return b?gcd(b,a%b):a; } ll lcm(ll a,ll b){ return a/gcd(a,b)*b; } int main(){ ll A,B,T; scanf("%lld%lld%lld",&A,&B,&T); ll l=lcm(A,B),g=gcd(A,B); if(T>=l){ printf("%lld\n",(T+l-1)/l*l); return 0; } ll mi=LLONG_MAX; for(int i=0;T>=B*i;i++){ mi=min((T-i*B+A-1)/A*A+B*i,mi); } printf("%lld\n",mi); return 0; }