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

int main () {
    ll n;
    cin >> n;
    ll ans = 0;
    rep(i, n) {
        if(1 % 3 == 0 && i % 5 == 0){}
        else if (i % 3 == 0) {}
        else if (i % 5 == 0) {}
        else {
            ans += i;
        }
    }
    printf("%ld\n",ans);
}
