#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define erep(i, n) for (int i = 0; i <= (n); i++)
#define erep1(i, n) for (int i = 1; i <= (n); i++)
using namespace std;
using ll = long long;


int main() {
    ll N;
    cin >> N;
    ll sum = 0;
    erep1(i, N) {
        if (i % 3 == 0) continue;
        if (i % 5 == 0) continue;
        sum += i;
    }
    cout << sum << endl;
}