from collections import deque

from copy import deepcopy

def factors(N):

    ret = []

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

        if N%i == 0:

            ret.append([])

            t = 1

            while N%i == 0:

                N //= i

                ret[-1].append(i**t)

                t += 1

    return ret

N = int( eval(input()))

F = factors(N)

C = deque([1])



for d in F:

    T = deepcopy(C)

    for t in T:

        for s in d:

            C.append(t*s)



ans = 0

for c in C:

    m = N//c -1

    if m == 0:

        continue

    if N//m == N%m:

        ans += m



print(ans)

def factors(N): #約数を全て求める。ただし、順不同

    from collections import deque

    ret = deque()

    middle = int( N**(1/2))

    for i in range(1, middle):

        if N%i == 0:

            ret.append(i)

            ret.append(N//i)

            

    if N%middle == 0:

        ret.append(middle)

        if middle != N//middle:

            ret.append(N//middle)

    return ret



def main():

    N = int( eval(input()))

    ans = 0

    for m in factors(N):

        if m==1:

            continue

        if N//(m-1)*m == N:

            ans += m-1

    print(ans)

    

if __name__ == '__main__':

    main()

from collections import deque
from copy import deepcopy


def factors(N):
    ret = []
    for i in range(2, int(N ** (1 / 2)) + 1):
        if N % i == 0:
            ret.append([])
            t = 1
            while N % i == 0:
                N //= i
                ret[-1].append(i**t)
                t += 1
    return ret


N = int(eval(input()))
F = factors(N)
C = deque([1])
for d in F:
    T = deepcopy(C)
    for t in T:
        for s in d:
            C.append(t * s)
ans = 0
for c in C:
    m = N // c - 1
    if m == 0:
        continue
    if N // m == N % m:
        ans += m
print(ans)

def factors(N):  # 約数を全て求める。ただし、順不同
    from collections import deque

    ret = deque()
    middle = int(N ** (1 / 2))
    for i in range(1, middle):
        if N % i == 0:
            ret.append(i)
            ret.append(N // i)
    if N % middle == 0:
        ret.append(middle)
        if middle != N // middle:
            ret.append(N // middle)
    return ret


def main():
    N = int(eval(input()))
    ans = 0
    for m in factors(N):
        if m == 1:
            continue
        if N // (m - 1) * m == N:
            ans += m - 1
    print(ans)


if __name__ == "__main__":
    main()

-from collections import deque -from copy import deepcopy +def factors(N):  # 約数を全て求める。ただし、順不同 +    from collections import deque - -def factors(N): -    ret = [] -    for i in range(2, int(N ** (1 / 2)) + 1): +    ret = deque() +    middle = int(N ** (1 / 2)) +    for i in range(1, middle): -            ret.append([]) -            t = 1 -            while N % i == 0: -                N //= i -                ret[-1].append(i**t) -                t += 1 +            ret.append(i) +            ret.append(N // i) +    if N % middle == 0: +        ret.append(middle) +        if middle != N // middle: +            ret.append(N // middle) -N = int(eval(input())) -F = factors(N) -C = deque([1]) -for d in F: -    T = deepcopy(C) -    for t in T: -        for s in d: -            C.append(t * s) -ans = 0 -for c in C: -    m = N // c - 1 -    if m == 0: -        continue -    if N // m == N % m: -        ans += m -print(ans) +def main(): +    N = int(eval(input())) +    ans = 0 +    for m in factors(N): +        if m == 1: +            continue +        if N // (m - 1) * m == N: +            ans += m - 1 +    print(ans) + + +if __name__ == "__main__": +    main()