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(reverse = True)

	return divisors



N = int(eval(input()))

div = make_divisors(N)

i = 0

ans = 0

m = div[0]

while m >= 1:

	q = N // m

	r = N % m

	if q == r:

		ans += m

		i += 1

		m = div[i]

	else:

		m -= 1

print(ans)

N = int(eval(input()))

ans = 0



div = []  # Nの約数を全列挙してdivとする

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

	if N % i == 0:

		div.append(i)

		if i != N // i:

			div.append(N // i)



for j in range(len(div)):

	if div[j] == 1:  # m=0はskip

		pass

	else:

		m = div[j] - 1

		if N // m == N % m:

			ans += m



print(ans)

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(reverse=True)
    return divisors


N = int(eval(input()))
div = make_divisors(N)
i = 0
ans = 0
m = div[0]
while m >= 1:
    q = N // m
    r = N % m
    if q == r:
        ans += m
        i += 1
        m = div[i]
    else:
        m -= 1
print(ans)

N = int(eval(input()))
ans = 0
div = []  # Nの約数を全列挙してdivとする
for i in range(1, int(N**0.5) + 1):
    if N % i == 0:
        div.append(i)
        if i != N // i:
            div.append(N // i)
for j in range(len(div)):
    if div[j] == 1:  # m=0はskip
        pass
    else:
        m = div[j] - 1
        if N // m == N % m:
            ans += m
print(ans)

-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(reverse=True) -    return divisors - - -div = make_divisors(N) -i = 0 -m = div[0] -while m >= 1: -    q = N // m -    r = N % m -    if q == r: -        ans += m -        i += 1 -        m = div[i] +div = []  # Nの約数を全列挙してdivとする +for i in range(1, int(N**0.5) + 1): +    if N % i == 0: +        div.append(i) +        if i != N // i: +            div.append(N // i) +for j in range(len(div)): +    if div[j] == 1:  # m=0はskip +        pass -        m -= 1 +        m = div[j] - 1 +        if N // m == N % m: +            ans += m