import sys

import os





def main():

    if os.getenv("LOCAL"):

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



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



    ret = float('inf')

    for i in range(1, 10000000):

        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



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


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")
    N = int(sys.stdin.readline().rstrip())
    ret = float("inf")
    for i in range(1, 10000000):
        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


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 math +    max = int(math.sqrt(N) + 1) -    for i in range(1, 10000000): +    for i in range(1, max):