input = gets

N = input.split(" ")[0].to_i

i = 1

arry = []
arry2 = []
zahyo = []

100.times do
  j = 1
  arry2 = []
  
  100.times do
    ans = i*j
    if ans == N
       
      ido = i + j -2
      p "#{i},#{j} ido = #{ido}"
      zahyo.push(ido)
    end
    
    arry2.push(ans)
    j += 1
  end
  
  arry[i] = (arry2)
  i += 1
end

p zahyo.min