import sys

import numpy as np

N = int(eval(input()))

for i in range(int(np.sqrt(N)), 0, -1):

  if N / i == int(N / i):

      print((int(N / i + i - 2)))

      sys.exit()

print((N - 1))
import math

N = int(eval(input()))

for i in range(int(math.sqrt(N)), 0, -1):

  if N / i == int(N / i):

      print((int(N / i + i - 2)))

      exit()
import sys
import numpy as np

N = int(eval(input()))
for i in range(int(np.sqrt(N)), 0, -1):
    if N / i == int(N / i):
        print((int(N / i + i - 2)))
        sys.exit()
print((N - 1))

import math

N = int(eval(input()))
for i in range(int(math.sqrt(N)), 0, -1):
    if N / i == int(N / i):
        print((int(N / i + i - 2)))
        exit()

-import sys -import numpy as np +import math -for i in range(int(np.sqrt(N)), 0, -1): +for i in range(int(math.sqrt(N)), 0, -1): -        sys.exit() -print((N - 1)) +        exit()