from math import * 
A=int(input())
EPS=1-10**-12
P=2*int(log(A,2)+EPS)
for i in range(3,P+1):
  P=min(P,i*int(log(A,i)+EPS))
print(P)