#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <map>
using namespace std;

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