import sys

import math

import itertools

import collections

import heapq

import re

import numpy as np



rr = lambda: sys.stdin.buffer.readline().rstrip()

rs = lambda: sys.stdin.buffer.readline().split()

ri = lambda: int(sys.stdin.buffer.readline())

rm = lambda: list(map(int, sys.stdin.buffer.readline().split()))

rl = lambda: list(map(int, sys.stdin.buffer.readline().split()))



m = float('inf')

n = ri()

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

  a = n//i

  if a*i == n:

    if m > a+i:

      m = a+i

else:

  print((m-2))





import sys

import math

import itertools

import collections

import heapq

import re

import numpy as np



rr = lambda: sys.stdin.buffer.readline().rstrip()

rs = lambda: sys.stdin.buffer.readline().split()

ri = lambda: int(sys.stdin.buffer.readline())

rm = lambda: list(map(int, sys.stdin.buffer.readline().split()))

rl = lambda: list(map(int, sys.stdin.buffer.readline().split()))



n = ri()

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

    if not n%i:

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

        exit()





import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.buffer.readline().rstrip()
rs = lambda: sys.stdin.buffer.readline().split()
ri = lambda: int(sys.stdin.buffer.readline())
rm = lambda: list(map(int, sys.stdin.buffer.readline().split()))
rl = lambda: list(map(int, sys.stdin.buffer.readline().split()))
m = float("inf")
n = ri()
for i in range(1, int(n**0.5) + 1):
    a = n // i
    if a * i == n:
        if m > a + i:
            m = a + i
else:
    print((m - 2))

import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.buffer.readline().rstrip()
rs = lambda: sys.stdin.buffer.readline().split()
ri = lambda: int(sys.stdin.buffer.readline())
rm = lambda: list(map(int, sys.stdin.buffer.readline().split()))
rl = lambda: list(map(int, sys.stdin.buffer.readline().split()))
n = ri()
for i in range(int(n**0.5), 0, -1):
    if not n % i:
        print((n // i + i - 2))
        exit()

-m = float("inf") -for i in range(1, int(n**0.5) + 1): -    a = n // i -    if a * i == n: -        if m > a + i: -            m = a + i -else: -    print((m - 2)) +for i in range(int(n**0.5), 0, -1): +    if not n % i: +        print((n // i + i - 2)) +        exit()