#include <bits/stdc++.h>
using namespace std;
void fileIO() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
#ifdef ONLINE_JUDGE
#endif
}
int TC;
void get_shit_done() {
long long n;
cin >> n;
vector<long long> v;
for (long long i = 1; i * i <= n; ++i) {
if (n % i == 0) {
v.push_back(i + n / i);
}
}
sort(v.rbegin(), v.rend());
long long ans = 0;
for (int i = 0; i + 1 < int(v.size()); ++i) {
ans += v[i] - v[i + 1];
}
cout << ans;
}
signed main() {
fileIO();
cin.tie(nullptr);
cout.tie(nullptr);
ios::sync_with_stdio(false);
int T = 1;
for (TC = 1; TC <= T; ++TC) {
get_shit_done();
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKdm9pZCBmaWxlSU8oKSB7CiNpZm5kZWYgT05MSU5FX0pVREdFCiAgICBmcmVvcGVuKCJpbnB1dC50eHQiLCAiciIsIHN0ZGluKTsKICAgIGZyZW9wZW4oIm91dHB1dC50eHQiLCAidyIsIHN0ZG91dCk7CiNlbmRpZgoKI2lmZGVmIE9OTElORV9KVURHRQojZW5kaWYKfQoKaW50IFRDOwoKdm9pZCBnZXRfc2hpdF9kb25lKCkgewogICAgbG9uZyBsb25nIG47CiAgICBjaW4gPj4gbjsKCiAgICB2ZWN0b3I8bG9uZyBsb25nPiB2OwogICAgZm9yIChsb25nIGxvbmcgaSA9IDE7IGkgKiBpIDw9IG47ICsraSkgewogICAgICAgIGlmIChuICUgaSA9PSAwKSB7CiAgICAgICAgICAgIHYucHVzaF9iYWNrKGkgKyBuIC8gaSk7CiAgICAgICAgfQogICAgfQogICAgc29ydCh2LnJiZWdpbigpLCB2LnJlbmQoKSk7CgogICAgbG9uZyBsb25nIGFucyA9IDA7CiAgICBmb3IgKGludCBpID0gMDsgaSArIDEgPCBpbnQodi5zaXplKCkpOyArK2kpIHsKICAgICAgICBhbnMgKz0gdltpXSAtIHZbaSArIDFdOwogICAgfQoKICAgIGNvdXQgPDwgYW5zOwp9CgpzaWduZWQgbWFpbigpIHsKICAgIGZpbGVJTygpOwogICAgY2luLnRpZShudWxscHRyKTsKICAgIGNvdXQudGllKG51bGxwdHIpOwogICAgaW9zOjpzeW5jX3dpdGhfc3RkaW8oZmFsc2UpOwoKICAgIGludCBUID0gMTsKICAgIGZvciAoVEMgPSAxOyBUQyA8PSBUOyArK1RDKSB7CiAgICAgICAgZ2V0X3NoaXRfZG9uZSgpOwogICAgfQoKICAgIHJldHVybiAwOwp9