#include<cstring>
#include<iostream>
#include<algorithm>
#include<string>
#define rep(i,n) for (int i = 1; i <= (n); ++i)
using ll = long long;
using namespace std;

int main() {
    ll n;
    cin >> n;
    ll count = 0;
    rep(i, n) {
        if (i % 3 != 0) {
            if (i % 5 != 0) {
                count += i;
            }
        }
    }
    cout << count << endl;
    return 0;
}