#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

void ok(int N)
{
    bool ok = false;
    while (N)
    {
        if (N % 10 == 7)
        {
            cout << "Yes" << endl;
            return;
        }
        N /= 10;
    }
    cout << "No" << endl;
    return;
}

int main()
{
    int N;
    cin >> N;
    ll ans = 0;
    for (int i = 1; i < N + 1; i++)
    {
        if (i % 3 != 0 && i % 5 != 0)
        {
            ans += i;
        }
    }

    cout << ans << endl;
    return 0;
}
