n = int(input()) ans = n pow_num = 2 while int(n**(1/pow_num)) > 1: f = int(n**(1/pow_num)) r = n - pow(f, pow_num) ans = min(ans, f + pow_num + r) pow_num += 1 print(ans)