N = int(input()) ans = N for j in range(60+1): high = N low = 1 while high-low>1: mid = (high+low)//2 if pow(mid,j)<=N: low = mid else: high = mid ans = min(ans,low+j+N-pow(low,j)) print(ans)