import sys input = lambda :sys.stdin.readline()[:-1] ni = lambda :int(input()) na = lambda :list(map(int,input().split())) sys.setrecursionlimit(10**7) yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES") no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO") ####################################################################### n = ni() ans = n-1 def f(x): ng = 2*10**18 ok = 0 while ng-ok>1: d = (ok+ng)//2 if d**x<=n: ok = d else: ng = d return ok for b in range(2,100): a = f(b) ans = min(ans,b+a+n-a**b) #print(b+a+n-a**b) print(ans)