#include<iostream>
#include<vector>
using namespace std;

int main() {
    long long n, sum = 0;
    cin >> n;

    for (int i = 0; i < n; i++) {
        if ((i + 1) % 3 != 0 && (i + 1) % 5 != 0) {
            sum += (i+1);
        }
    }

    cout << sum << endl;
}