""" """ import sys from sys import stdin n = int(stdin.readline()) ans = n for i in range(2,1000000): x = 1 cnt = 0 while x * i <= n: x *= i cnt += 1 k = n - x ans = min(ans , i + cnt + k) print (ans)