#include <iostream>

using namespace std;

int main()
{
    unsigned int n;
    unsigned long long total = 0;
    cin >> n;
    for (unsigned int i = 0; i < n; i++)
    {
        if (i % 3 != 0 && i % 5 != 0) total += i;
    }
    cout << total;

}