#include <bits/stdc++.h>

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#define PRINTP(p)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#p<<" = ("<<(p.first)<<", "<<(p.second)<<")"<<endl;
#define PRINTI(a,i)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<#i<<"] = "<<#a<<"["<<(i)<<"] = "<<(a)[i]<<endl;
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#define PRINTP(p)
#define PRINTI(a,i)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};



// assume that [p_first, p_last) contains all primes p such that
// p * p <= n
template <class Iterator>
vector<pair<unsigned long long, int>> factorize(unsigned long long n, Iterator p_first, Iterator p_last)
{
    vector<pair<unsigned long long, int>>result;
    for (Iterator p = p_first; p != p_last; ++p) {
        if ((*p) * (*p) > n) {
            if (n > 1) {
                result.push_back(pair<unsigned long long, int>(n, 1));
            }
            break;
        }
        int count = 0;
        while (n % (*p) == 0) {
            n /= (*p);
            ++count;
        }
        if (count) {
            result.push_back(pair<unsigned long long, int>(*p, count));
            if (n == 1) {
                break;
            }
        }
    }
    return result;
}


vector<ull> primes_less_than(ull n) {
    vector<ull> ps;
    ps.pb(2);
    for (int m = 3; m < n; m += 2) {
        bool is_prime = true;
        for (ull p: ps) {
            if (p * p > m) {
                break;
            }
            if (m % p == 0) {
                is_prime = false;
                break;
            }
        }
        if (is_prime) {
            ps.pb(m);
        }
    }
    return ps;
}


ull naive(ull N) {
    ull result = 0;
    FOR(m, 1, N + 1) {
        if (N / m == N % m) {
            //printf("m = %d is favorite\n", m);
            result += m;
        }
    }
    return result;
}

vector<ull> divs(ull N) {
    vector<ull> ds;
    ds.pb(1);

    auto primes = primes_less_than(1001000);
    //PRINTA(primes, 0, primes.size());

    auto factors = factorize(N, all(primes));

    for (auto z: factors) {
        ull L = ds.size();
        ull p, e;
        p = z.first;
        e = z.second;

        ull pow_p_i = 1;
        FOR(i, 1, e + 1) {
            pow_p_i *= p;
            REP(j, L) {
                ds.pb(ds[j] * pow_p_i);
            }
        }
    }

    return ds;
}

ull solve(ull N) {
    auto ds = divs(N);
    //PRINTA(ds, 0, ds.size());

    ull result = 0;
    FOR(i, 1, ds.size()) {
        ull d = ds[i];
        ull m = d - 1;
        if (N / m == N % m) {
            result += m;
        }
    }
    return result;
}

int main(void) {
    ll N;
    cin >> N;
    
    cout << solve(N) << endl;

    /*
    FOR(i, 1, 10000) {
        PRINT(i);
        ull ret1 = naive(i);
        ull ret2 = solve(i);
        if (ret1 != ret2) {
            printf("diff\n");
            PRINT(i);
            PRINT(ret1);
            PRINT(ret2);
        } else {
            printf("%d is ok\n", i);
        }
    }
    */



    /*
    REP(i, factors.size()) {
        PRINTP(factors[i]);
    }
    */



    return 0;
}



Measured memory_bytes: 1400