#include using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); unsigned long long A, B, C; cin >> A >> B >> C; // 1歳で終了(例外) if (C == 1) { cout << 1; } else { unsigned long long delta = (A - 1); // A歳に到達することなく終了 if (delta > C) { cout << C; } else { unsigned long long delta2 = delta + B; // A歳ぴったりで終了 if (delta2 > C) { cout << A; } else { unsigned long long n = (unsigned long long)(C / delta2); if (delta + n*delta2 > C) { cout << C + n * (A - delta2); } else { cout << A + A * n; } } } } }