#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll N;

void solve() {
    cin >> N;
    ll count = 0;
    for (ll i = 0; i < N; ++i) {
        if (!(i % 5 == 0 || i % 3 == 0)) {
            count += i;
        };
    }
    cout << count << endl;

}

int main() {
    solve();
    return 0;
}
