# N//m=N%m

# (N-N%m)/m=N%m

# N=(N%m)(m+1)



n=int(eval(input()))



def make_divisor(x):

    ret=[]

    for i in range(1,int(x**.5)+1):

        q,m=divmod(x,i)

        if m==0:

            ret.append(i)

            if i==q:continue

            ret.append(q)

    return ret



ans=[]

d=make_divisor(n)



for e in d:

    if e==1:continue

    m=e-1

    k=n%m

    if k*e==n:

        ans.append(m)

print((sum(ans)))
# N//m==N%m=k

# N=k*m+k=k(m+1)=kM

N=int(eval(input()))

arr=[]

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

    if N%i==0:

        arr.append(N//i)

        if N//i!=i:

            arr.append(i)

arr.sort()



ans=0

for M in arr:

    m=M-1

    if m==0:continue

    if N%m==N//m:

        ans+=m

print(ans)

        

# N//m=N%m
# (N-N%m)/m=N%m
# N=(N%m)(m+1)
n = int(eval(input()))


def make_divisor(x):
    ret = []
    for i in range(1, int(x**0.5) + 1):
        q, m = divmod(x, i)
        if m == 0:
            ret.append(i)
            if i == q:
                continue
            ret.append(q)
    return ret


ans = []
d = make_divisor(n)
for e in d:
    if e == 1:
        continue
    m = e - 1
    k = n % m
    if k * e == n:
        ans.append(m)
print((sum(ans)))

# N//m==N%m=k
# N=k*m+k=k(m+1)=kM
N = int(eval(input()))
arr = []
for i in range(1, int(N**0.5) + 1):
    if N % i == 0:
        arr.append(N // i)
        if N // i != i:
            arr.append(i)
arr.sort()
ans = 0
for M in arr:
    m = M - 1
    if m == 0:
        continue
    if N % m == N // m:
        ans += m
print(ans)

-# N//m=N%m -# (N-N%m)/m=N%m -# N=(N%m)(m+1) -n = int(eval(input())) - - -def make_divisor(x): -    ret = [] -    for i in range(1, int(x**0.5) + 1): -        q, m = divmod(x, i) -        if m == 0: -            ret.append(i) -            if i == q: -                continue -            ret.append(q) -    return ret - - -ans = [] -d = make_divisor(n) -for e in d: -    if e == 1: +# N//m==N%m=k +# N=k*m+k=k(m+1)=kM +N = int(eval(input())) +arr = [] +for i in range(1, int(N**0.5) + 1): +    if N % i == 0: +        arr.append(N // i) +        if N // i != i: +            arr.append(i) +arr.sort() +ans = 0 +for M in arr: +    m = M - 1 +    if m == 0: -    m = e - 1 -    k = n % m -    if k * e == n: -        ans.append(m) -print((sum(ans))) +    if N % m == N // m: +        ans += m +print(ans)