#include // #include using namespace std; // using namespace atcoder; typedef int64_t lint; #define rep(i, n) for(int i=0; i; using vvi = vector>; template inline void vin(vector& v) { rep(i, v.size()) cin >> v.at(i); } template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } template inline void drop(T x) { cout << x << endl; exit(0); } template void vout(vector v) { rep(i, v.size()) { cout << v.at(i) << ' '; } cout << endl; } constexpr lint LINF = LLONG_MAX/2; using tint = tuple; using vt = vector; int main() { lint A, B, N; cin >> A >> B >> N; if (N == 1) drop(0); lint a=0, b=0, c=0, x, y, z, ans=LINF; priority_queue, greater> q; q.push({A, -1, -1}); while (true) { tie(x, y, z) = q.top(); q.pop(); y *= -1; z *= -1; if (x > ans) break; if (chmax(a, x)) { b = 0, c = 0; } else if (!chmax(b, y) && !chmax(c, z)) { continue; } if (N >= y) chmin(ans, x+B*((N-y+z-1)/z)); // list(x) // list(y) // list(z) // show(ans) if (B*((N-y+z-1)/z) < A) break; if (y == z) { q.push({x+B, -(y+z), -z}); } else { q.push({x+B, -(y+z), -z}); q.push({x+A, -y, -y}); } } std::cout << ans << '\n'; }