#include #include #include #include #include #define REP(i,k,n) for(int i=k;i memo; void dfs(int x) { if(memo[x]) 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; }