#include using lint = long long; constexpr lint INF = 1LL << 60; void solve() { lint a, b, t; std::cin >> a >> b >> t; auto ans = INF; if (a * a <= t) { for (lint y = 0; y < a; ++y) { if (b * y >= t) { ans = std::min(ans, b * y); break; } auto r = t - b * y; auto x = (r + a - 1) / a; ans = std::min(ans, a * x + b * y); } } else { for (lint x = 0;; ++x) { if (a * x >= t) { ans = std::min(ans, a * x); break; } auto r = t - a * x; auto y = (r + b - 1) / b; ans = std::min(ans, a * x + b * y); } } std::cout << ans << "\n"; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); solve(); return 0; }