#include using namespace std; using lint = long long; template T modpow(T a, T b, T mod=(1LL<<60)) { T res = 1; while (b > 0) { if (b&1) (res *= a) %= mod; (a *= a) %= mod; b >>= 1; } return res; } template bool is_prime(T n) { if (n <= 1) return false; for (T i = 2; i*i <= n; i++) { if (n%i == 0) return false; } return true; } int main() { lint n; cin >> n; lint ans = 0; for (lint i = 2; i*i <= n; i++) { if (!is_prime(i)) continue; for (lint j = 2; ; j++) { if (modpow(i, j) <= n) ans += modpow(i, j); else break; } } cout << ans << endl; }