n = int(eval(input()))

import math

for i in range(math.floor(n**0.5),0,-1):

  if n % i == 0:

    print((i + n//i -2))

    break
n = int(eval(input()))

for i in range(int(n**0.5)+1,0,-1):

  if n % i == 0:

    print((i + n//i -2))

    break
n = int(eval(input()))
import math

for i in range(math.floor(n**0.5), 0, -1):
    if n % i == 0:
        print((i + n // i - 2))
        break

n = int(eval(input()))
for i in range(int(n**0.5) + 1, 0, -1):
    if n % i == 0:
        print((i + n // i - 2))
        break

-import math - -for i in range(math.floor(n**0.5), 0, -1): +for i in range(int(n**0.5) + 1, 0, -1):