import math N = int(input()) ans = N for j in range(2,80): i = int(pow(N,1/j)) ans = min(ans,i+j+(N-i**j)) print(ans)