def get_int
  gets.chop.to_i
end

def get_ints
  gets.chop.split.map(&:to_i)
end

def get_double
  gets.chop.to_f
end

def get_str
  gets.chop
end

def get_strs
  gets.chop.split
end

def main
  n = get_int
  sq = Math.sqrt(n)
  divs = []
  1.upto(sq) do |i|
    if n % i == 0
      divs << [i, n/i]
    end
  end

  a, b = divs[-1]
  puts (a - 1 + b - 1)
end

if __FILE__ == $0
  main
end
