#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define ALL(x) begin(x), end(x)
#define dump(x) cerr << #x " = " << x << endl
using ll = long long;
using namespace std;
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
template <class T, class U> inline void chmax(T & a, U const & b) { a = max<T>(a, b); }
template <class T, class U> inline void chmin(T & a, U const & b) { a = min<T>(a, b); }
template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }
template <typename T> ostream & operator << (ostream & out, vector<T> const & xs) { REP (i, int(xs.size()) - 1) out << xs[i] << ' '; if (not xs.empty()) out << xs.back(); return out; }

/**
 * @note O(\sqrt{n})
 * @note about 1.0 sec for 10^5 queries with n < 10^10
 */
struct prepared_primes {
    int size;
    vector<int> sieve;
    vector<int> primes;

    prepared_primes(int size_)
        : size(size_) {

        sieve.resize(size);
        REP3 (p, 2, size) if (sieve[p] == 0) {
            primes.push_back(p);
            for (int k = p; k < size; k += p) {
                if (sieve[k] == 0) {
                    sieve[k] = p;
                }
            }
        }
    }

    vector<ll> prime_factorize(ll n) {
        assert (1 <= n and n < (ll)size * size);
        vector<ll> result;

        // trial division for large part
        for (int p : primes) {
            if (n < size or n < (ll)p * p) {
                break;
            }
            while (n % p == 0) {
                n /= p;
                result.push_back(p);
            }
        }

        // small part
        if (n == 1) {
            // nop
        } else if (n < size) {
            while (n != 1) {
                result.push_back(sieve[n]);
                n /= sieve[n];
            }
        } else {
            result.push_back(n);
        }

        assert (is_sorted(ALL(result)));
        return result;
    }

    bool is_prime(ll n) {
        return prime_factorize(n).size() == 1;
    }

    vector<ll> all_factorize(ll n) {
        auto p = prime_factorize(n);
        vector<ll> d;
        d.push_back(1);
        for (int l = 0; l < p.size(); ) {
            int r = l + 1;
            while (r < p.size() and p[r] == p[l]) ++ r;
            int n = d.size();
            REP (k1, r - l) {
                REP (k2, n) {
                    d.push_back(d[d.size() - n] * p[l]);
                }
            }
            l = r;
        }
        return d;
    }
};
prepared_primes primes(1e7);


ll solve(ll n) {
    ll acc = 0;
    vector<ll> factors = primes.all_factorize(n);
    for (ll q : factors) {
        ll m = n / q - 1;
        if (m != 0 and n / m == n % m) {
            acc += m;
        }
    }
    return acc;
}

int main() {
    ll n; cin >> n;
    cout << solve(n) << endl;
    return 0;
}


Measured memory_bytes: 45424