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

int n, total = 0;

int main()
{
    ios_base::sync_with_stdio(false);
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        if (i % 3 != 0 && i % 5 != 0)
        {
            total += i;
        }
    }

    cout << total;
}