n = int(input()) import math ans = 10 ** 20 for j in range(0,100): if j == 0: ans = min(ans, 1 + 0 + n - 1) elif j == 1: ans = min(ans, n + 1) else: for i in range(1,n + 1): if i ** j >= n: break i -= 1 ans = min(ans, i + j + n - i ** j) print(ans)