m=N=gets.to_i y=(1..N**0.5).select{|i|N%i==0} y.each{|a|y.each{|b|z=a+b+N/(a*b)-3;N%(a*b)==0&&m>z&&m=z}} $><<[m,N-1]*' '