import sys

import os

import math



def main():

    if os.getenv("LOCAL"):

        sys.stdin = open("input.txt", "r")



    N = int(sys.stdin.readline().rstrip())



    max = int(math.sqrt(N) + 1)

    ret = float('inf')

    for i in range(1, max):

        q, mod = divmod(N, i)

        if mod == 0:

            j = N // i

            ret = min(ret, ((j-1)+(i-1)))



    print(ret)





if __name__ == '__main__':

    main()

import sys

import os

import math



ii = lambda: int(sys.stdin.buffer.readline().rstrip())

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

iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]



iss = lambda: sys.stdin.buffer.readline().decode().rstrip()

isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]





def main():

    if os.getenv("LOCAL"):

        sys.stdin = open("input.txt", "r")



    N = ii()

    T = int(math.sqrt(N))

    ret = float('inf')

    for i in range(1, T+1):

        if N % i == 0:

            ret = min(ret, N//i+i-2)

    print(ret)





if __name__ == '__main__':

    main()

import sys
import os
import math


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")
    N = int(sys.stdin.readline().rstrip())
    max = int(math.sqrt(N) + 1)
    ret = float("inf")
    for i in range(1, max):
        q, mod = divmod(N, i)
        if mod == 0:
            j = N // i
            ret = min(ret, ((j - 1) + (i - 1)))
    print(ret)


if __name__ == "__main__":
    main()

import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]
iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")
    N = ii()
    T = int(math.sqrt(N))
    ret = float("inf")
    for i in range(1, T + 1):
        if N % i == 0:
            ret = min(ret, N // i + i - 2)
    print(ret)


if __name__ == "__main__":
    main()

+ +ii = lambda: int(sys.stdin.buffer.readline().rstrip()) +il = lambda: list(map(int, sys.stdin.buffer.readline().split())) +iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)] +iss = lambda: sys.stdin.buffer.readline().decode().rstrip() +isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)] -    N = int(sys.stdin.readline().rstrip()) -    max = int(math.sqrt(N) + 1) +    N = ii() +    T = int(math.sqrt(N)) -    for i in range(1, max): -        q, mod = divmod(N, i) -        if mod == 0: -            j = N // i -            ret = min(ret, ((j - 1) + (i - 1))) +    for i in range(1, T + 1): +        if N % i == 0: +            ret = min(ret, N // i + i - 2)