#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//cout << fixed << setprecision(17) << res << endl;
 
int main() {
    ll res = 0;
    ll n;
    cin >> n;
    for (ll i = 1; i <= n; ++i) {
        if (i%3 == 0) continue;
        if (i%5 == 0) continue;
        res += i;
    }
    cout << res << endl;
}
