"""

author : halo2halo

date : 4, Feb, 2020

"""



import sys

import itertools



# import math



import numpy as np



read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines

INF = 10 ** 13



N = int(readline())

temp = INF

a = 0

b = 0

for i in range(1, int(N**.5)+1):

    if N % i == 0:

        if temp >= abs(i - N // i):

            temp = abs(i - N // i)

            a = i

            b = N // i

print((a+b-2))
"""

author : halo2halo

date : 4, Feb, 2020

"""



import sys

import itertools



# import math



# import numpy as np



read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines

INF = 10 ** 13



N = int(readline())

temp = INF

a = 0

b = 0

for i in range(1, int(N**.5)+1):

    if N % i == 0:

        if temp >= abs(i - N // i):

            temp = abs(i - N // i)

            a = i

            b = N // i

print((a+b-2))







"""
author : halo2halo
date : 4, Feb, 2020
"""
import sys
import itertools

# import math
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
INF = 10**13
N = int(readline())
temp = INF
a = 0
b = 0
for i in range(1, int(N**0.5) + 1):
    if N % i == 0:
        if temp >= abs(i - N // i):
            temp = abs(i - N // i)
            a = i
            b = N // i
print((a + b - 2))

"""
author : halo2halo
date : 4, Feb, 2020
"""
import sys
import itertools

# import math
# import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
INF = 10**13
N = int(readline())
temp = INF
a = 0
b = 0
for i in range(1, int(N**0.5) + 1):
    if N % i == 0:
        if temp >= abs(i - N // i):
            temp = abs(i - N // i)
            a = i
            b = N // i
print((a + b - 2))

-import numpy as np - +# import numpy as np