#include using namespace std; #define ALL(x) begin(x),end(x) #define rep(i,n) for(int i=0;i<(n);i++) #define debug(v) cout<<#v<<":";for(auto x:v){cout<bool chmax(T &a,const T &b){if(abool chmin(T &a,const T &b){if(b ostream &operator<<(ostream &os,const vector&v){ for(int i=0;i<(int)v.size();i++) os< istream &operator>>(istream &is,vector&v){ for(T &x:v)is>>x; return is; } const ll m=100000; signed main(){ ll a,b,t;cin>>a>>b>>t; if(b<=m){ vector v(a,0); for(ll tot=0;tot<=t;tot+=b) v[(t-tot)%a]=1; ll res=LINF; if(v[0]) res=t; rep(i,a)if(v[i]) chmin(res,t+a-i); cout<