#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

int main()
{
    long n;
    long long acc = 0;
    cin >> n;
    for (long i =  1; i <= n; i++) {
        if (i % 3 == 0 || i % 5 == 0)
            continue;
        acc += i;
    }
    cout << acc << endl;
    return 0;
}