a=int(eval(input()))

 

def make_divisors(n):

    divisors = []

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

        res=[]

        if n % i == 0:

            res.append(i)

            if i != n // i:

                res.append(n//i)

        if res!=[]:

            divisors.append(res)

    return divisors

 

res=make_divisors(a)

my_min=0

for i in range(len(res)):

    if i==0:

        if len(res[i])==2:

            my_min=res[i][0]+res[i][1]

        else:

            my_min=(res[i][0]*2)

    else:

        if len(res[i])==2:

            my_min=min(my_min,res[i][0]+res[i][1])

        else:

            my_min=min(my_min,res[i][0]*2)

 

print((my_min-2))
n=int(eval(input()))

def make_divisors(n):

    divisors = []

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

        if n % i == 0:

            divisors.append(i)

            if i != n // i:

                divisors.append(n//i)



    # divisors.sort()

    return divisors

a=make_divisors(n)

#print(a)

if a[-1]**2==n:

    print((a[-1]*2-2))

else:

    print((a[-1]+a[-2]-2))
a = int(eval(input()))


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5) + 1):
        res = []
        if n % i == 0:
            res.append(i)
            if i != n // i:
                res.append(n // i)
        if res != []:
            divisors.append(res)
    return divisors


res = make_divisors(a)
my_min = 0
for i in range(len(res)):
    if i == 0:
        if len(res[i]) == 2:
            my_min = res[i][0] + res[i][1]
        else:
            my_min = res[i][0] * 2
    else:
        if len(res[i]) == 2:
            my_min = min(my_min, res[i][0] + res[i][1])
        else:
            my_min = min(my_min, res[i][0] * 2)
print((my_min - 2))

n = int(eval(input()))


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
    # divisors.sort()
    return divisors


a = make_divisors(n)
# print(a)
if a[-1] ** 2 == n:
    print((a[-1] * 2 - 2))
else:
    print((a[-1] + a[-2] - 2))

-a = int(eval(input())) +n = int(eval(input())) -        res = [] -            res.append(i) +            divisors.append(i) -                res.append(n // i) -        if res != []: -            divisors.append(res) +                divisors.append(n // i) +    # divisors.sort() -res = make_divisors(a) -my_min = 0 -for i in range(len(res)): -    if i == 0: -        if len(res[i]) == 2: -            my_min = res[i][0] + res[i][1] -        else: -            my_min = res[i][0] * 2 -    else: -        if len(res[i]) == 2: -            my_min = min(my_min, res[i][0] + res[i][1]) -        else: -            my_min = min(my_min, res[i][0] * 2) -print((my_min - 2)) +a = make_divisors(n) +# print(a) +if a[-1] ** 2 == n: +    print((a[-1] * 2 - 2)) +else: +    print((a[-1] + a[-2] - 2))