import math, strutils, sequtils var A, B: int (A, B) = stdin.readline.split.map parseInt var N = stdin.readline.parseInt if N == 1: echo 0 quit 0 var ans = high(int) for i in 1..N: var a = int(floor(pow(float(N), 1 / i))) b = int(ceil(pow(float(N), 1 / i))) var powa, powb = newSeq[int](i + 1) powa[0] = 1 powb[0] = 1 for i in 1..i: powa[i] = powa[i - 1] * a powb[i] = powb[i - 1] * b for j in 0..i: if powa[j] * powb[i - j] >= N: ans = min(ans, (A + B * (a - 1)) * j + (A + B * (b - 1)) * (i - j)) if b == 2: break echo ans