#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i < (int)(n); i++)
using ull = unsigned long long;
using ll = long long;

int main() {
    int N;
    cin >> N;

    ll ans = 0;
    rep(i, N+1) {
        if ((i%5 != 0) && (i%3 != 0)) ans += i;
    }

    cout << ans << endl;

    return 0;
}

