import std.stdio, std.algorithm, std.conv, std.string, std.array;

void main()
{
  const N = readln.chomp.to!long;
  
  auto ans = long.max;
  for (long i = 1; i*i <= N; ++i) {
    if (N%i == 0) ans = ans.min(i+N/i-2);
  }
  ans.writeln;
}