import sys import math n = int(input()) ans = n for i in range(2, 61): l = 1 r = n while r - l > 1: m = (l + r) // 2 if (m**i) > n: r = m else: l = m ans = min(ans, l + i + n - (l**i)) print(ans)