import sys input = sys.stdin.readline n=int(input()) ANS=n for i in range(2,100): x=int(n**(1/i)) ANS=min(ANS,i+x+n-x**i) print(ANS)