#include <iostream>
using namespace std;
#include <bits/stdc++.h>
bool childporn(int n)
{
float temp = sqrt(n);
if(ceil(temp) != floor(temp))
return false;
return true;
}
long long sum_all_square(int n)
{
long long ans;
for(int i = 1; i <= n; i++)
{
if(n % i == 0)
if(childporn(i))
ans += i;
}
return ans;
}
int main()
{
int n;
cin >> n;
cout << sum_all_square(n);
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwojaW5jbHVkZSA8Yml0cy9zdGRjKysuaD4KCmJvb2wgY2hpbGRwb3JuKGludCBuKQp7CiAgICBmbG9hdCB0ZW1wID0gc3FydChuKTsKICAgIGlmKGNlaWwodGVtcCkgIT0gZmxvb3IodGVtcCkpCiAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgcmV0dXJuIHRydWU7Cn0KCmxvbmcgbG9uZyBzdW1fYWxsX3NxdWFyZShpbnQgbikKewogICAgbG9uZyBsb25nIGFuczsKICAgIGZvcihpbnQgaSA9IDE7IGkgPD0gbjsgaSsrKQogICAgewogICAgICAgIGlmKG4gJSBpID09IDApCiAgICAgICAgICAgIGlmKGNoaWxkcG9ybihpKSkKICAgICAgICAgICAgICAgIGFucyArPSBpOwogICAgfQogICAgcmV0dXJuIGFuczsKfQoKaW50IG1haW4oKQp7CiAgICBpbnQgbjsKICAgIGNpbiA+PiBuOwogICAgY291dCA8PCBzdW1fYWxsX3NxdWFyZShuKTsKfQoK