n = int(input()) ans = n for i in range(2,min(n+1,10**6+5)): x = 0 num = 1 while num <= n: num *= i x += 1 num //= i x -= 1 ans = min(ans,i+x+n-num) l = 1 r = n while r > l+1: m = (r+l)//2 if m**2 > n: r = m else: l = m ans = min(ans,l+2+n-l**2) print(ans)