import sys from operator import itemgetter import math stdin=sys.stdin sys.setrecursionlimit(10 ** 8) ip=lambda: int(sp()) fp=lambda: float(sp()) lp=lambda:list(map(int,stdin.readline().split())) sp=lambda:stdin.readline().rstrip() Yp=lambda:print('Yes') Np=lambda:print('No') inf = 1 << 60 eps = 1e-9 sortkey = itemgetter(0) n = ip() ans = n - 1 for j in range(1,int(math.log2(n)) + 1): i = int(pow(n, (1.0 / j))) while pow(i,j) <= n: i += 1 i -= 1 k = n - i ** j ans = min(ans, i + j + k) print(ans)