#yuki1664 n=int(input()) res=n for i in range(2,100): t=int(n**(1/i)) for x in range(t-3,t+3): if x>0 and x**i<=n: res=min(res,i+x+n-x**i) print(res)