from sys import maxsize from collections import deque a = int(input()) n, m = 2, 1 while n**m < a: m += 1 q = deque() q.append((n, m)) visited = set() ans = maxsize while len(q) > 0: n, m = q.popleft() if n >= 2 and m >= 1 and (n, m) not in visited: visited.add((n, m)) if n**m >= a: ans = min(ans, n * m) q.append((n + 1, m - 1)) q.append((n, m - 1)) q.append((n - 1, m)) print(ans)