n = int(input()) ans = n for i in range(2,min(n+1,10**6+5)): x = 0 num = 1 while num <= n: num *= i x += 1 num //= i x -= 1 ans = min(ans,i+x+n-num) print(ans)