A=gets.to_i p (2..7).map{|i|Math.ceil(Math.log(A,i))*i}.min