#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll M = 1e9 + 7;
const int iinf = 1 << 28;
const long long llinf = 1ll << 60;
const double PI = 3.14159265;

void work() {
    ll n; cin>>n;
    ll ans = 0;
    ll i = 1;
    ll terms = 0;
    while (i <= n) {
        if (i%3 != 0 && i%5 != 0) {
            ans += i;
        }
        ++i;
    }
    cout << ans << endl;
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    //int nt; cin>>nt; while (nt--) work();
    work();
    return 0;
}
