INF = 1000000000000000000 # N^12 より大きい数にする

inputs = Array.new
while line = $stdin.gets
  inputs << line.chomp
end
N = inputs[0].to_i

max = Math.sqrt(N).ceil
a = 1;

min_num = INF;

while a <= max
  if N % a == 0
    tmp = a + N/a - 2;
    min_num = tmp if min_num > tmp
  end
  a = a + 1;
end

puts min_num
