Snuke received a positive integer N from Takahashi. A positive integer m is called a _favorite number_ when the following condition is satisfied:    * The quotient and remainder of N divided by m are equal, that is, \lfloor \frac{N}{m} \rfloor = N \bmod m holds.  Find all favorite numbers and print the sum of those.

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

N = int(input())
a = make_divisors(N)
sum(a[len(a)//2:]) - len(a)//2


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

N = int(input())
a = make_divisors(N)
if N < 100000:
    ans = 0
    for n in range(1, N):
        a = N%n
        b = N//n

    #     print(n, a, b, a == b)
        if a == b:
            ans += n
#     print([ a +1 for a in anss], sum(anss), len(anss))
    print(ans)
else:
    if len(a)%2 == 0:
        print(sum(a[len(a)//2:]) - len(a)//2)
    else:
        print(sum(a[len(a)//2 + 1:]) - len(a)//2)