import std.stdio, std.conv, std.string, std.range, std.algorithm, std.array,
  std.functional, std.container, std.typecons, std.math;

void main() {
  ulong N = readln.chomp.to!ulong;
  ulong res = ulong.max;

  ulong m = 1 + cast(ulong)ceil(sqrt(cast(double)N));
  foreach(i; 1..m) {
    if(N % i == 0) {
      ulong j = N / i;
      res = min(res, i+j-2);
    }
  }
  res.writeln;
}
