#include<bits/stdc++.h>

using namespace std;
using ll = long long int;

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);

    ll n;
    cin >> n;
    ll s = 0;
    for(ll i=1; i<n; i++) {
        if(i%3 > 0 && i%5 > 0)
            s += i;
    }
    cout << s << endl;
}
