def solve(N):

    s = 1

    e = int(pow(N, 0.5)) + 1

    ds = []

    for i in range(s, e):

        if N % i == 0:

            m = (N // i) - 1

            if m and N // m == N % m:

                ds.append(N // i)

                # print(f"{N} = {m} * {N // m} + {N % m}")



    return sum([i - 1 for i in ds])





assert (solve(8) == 3 + 7)

assert (solve(10) == 4 + 9)

assert (solve(1000000000000) == 2499686339916)

if __name__ == "__main__":

    N = int(eval(input()))

    print((solve(N)))

def solve(N):

    s = 1

    e = int(pow(N, 0.5)) + 1

    ds = []

    for i in range(s, e):

        if N % i == 0:

            m = (N // i) - 1

            if m and N // m == N % m:

                ds.append(N // i)



    return sum([i - 1 for i in ds])



if __name__ == "__main__":

    N = int(eval(input()))

    print((solve(N)))

def solve(N):
    s = 1
    e = int(pow(N, 0.5)) + 1
    ds = []
    for i in range(s, e):
        if N % i == 0:
            m = (N // i) - 1
            if m and N // m == N % m:
                ds.append(N // i)
                # print(f"{N} = {m} * {N // m} + {N % m}")
    return sum([i - 1 for i in ds])


assert solve(8) == 3 + 7
assert solve(10) == 4 + 9
assert solve(1000000000000) == 2499686339916
if __name__ == "__main__":
    N = int(eval(input()))
    print((solve(N)))

def solve(N):
    s = 1
    e = int(pow(N, 0.5)) + 1
    ds = []
    for i in range(s, e):
        if N % i == 0:
            m = (N // i) - 1
            if m and N // m == N % m:
                ds.append(N // i)
    return sum([i - 1 for i in ds])


if __name__ == "__main__":
    N = int(eval(input()))
    print((solve(N)))

-                # print(f"{N} = {m} * {N // m} + {N % m}") -assert solve(8) == 3 + 7 -assert solve(10) == 4 + 9 -assert solve(1000000000000) == 2499686339916