import math def Next(): return input() def NextInt(): return int(Next()) def NextInts(): return map(int,input().split()) def Nexts(): return map(str,input().split()) def NextIntList(): return list(map(int,input().split())) def RowInts(n): return [int(input()) for i in range(n)] def cal(n, x): y = int(math.pow(n, 1/x)) ok, ng = 0, y*2 while ng - ok > 1: now =(ng+ok)//2 if now**x > n: ng = now else: ok = now return ok + x + (n-ok**x) n = int(input()) ans = n for i in range(2, 63): now = cal(n, i) if now < ans: ans = now print(ans)