#include <bits/stdc++.h>
using namespace std;

int64_t FizzBuzz(int64_t n) {
    int64_t i = 0;
    int64_t sum = 0;
    while (i < n) {
        i++;

        if (i % 3 == 0 || i % 5 == 0) {
            continue;
        } else {
            sum += i;
        }
    }

    return sum;
}

int main() {
    int64_t n;
    cin >> n;
    cout << FizzBuzz(n) << endl;
}