#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(j, m) for (int j = 0; i < (int)(n); j++)
using ll = long long;
using namespace std;

int main()
{
    int n;
    cin >> n;
    ll s = 0;
    rep(i, n + 1)
    {
        if (i % 3 != 0 || i % 5 != 0)
        {
            s += i;
        }
    }
    cout << s << endl;
}