#include #include #include #include #include #define REP(i,k,n) for(int i=k;i memo; void dfs(ll x) { if(memo[x]) return; if(x > ans) return; if(x >= t) { ans = min(ans,x); return; } memo[x] = true; dfs(x+a); dfs(x+b); } int main() { cin >> a >> b >> t; dfs(0); cout << ans << endl; return 0; }