#include using namespace std; using ll = long long; void chmin(ll& a, ll b) { if (a > b) a = b; } ll my_pow(ll a, ll b) { ll res = 1; while (b) { if (b & 1) res *= a; a *= a; b >>= 1; } return res; } ll kth_root(ll k, ll n) { if (n <= 1 || k == 1) return n; ll res = pow(n, 1.0 / k); while (my_pow(res, k) > n) --res; while (my_pow(res + 1, k) <= n) ++res; return res; } int main() { ll A, B, N; cin >> A >> B >> N; if (N == 1) { puts("0"); return 0; } ll ans = 1e18; for (int i = 1; (1ull << (i - 1)) < N; ++i) { ll a = kth_root(i, N); ll b = a + 1; vector powa(i + 1), powb(i + 1); powa[0] = powb[0] = 1; for (int j = 0; j < i; ++j) powa[j + 1] = min(powa[j] * a, N); for (int j = 0; j < i; ++j) powb[j + 1] = min(powb[j] * b, N); for (int j = 0; j <= i; ++j) { if (powa[j] * powb[i - j] >= N) { chmin(ans, (A + (a - 1) * B) * j + (A + (b - 1) * B) * (i - j)); } } } cout << ans << endl; }