#include <bits/stdc++.h>

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl
#define debug2(s, t, u) cout << s << " " << t << " " << u << endl
#define printvec(v)       \
    for (auto &&i : v)    \
        cout << i << " "; \
    cout << endl

using namespace std;
using i64 = long long;

int main()
{
    int n;
    cin >> n;

    i64 sum = 0;

    for (int i = 1; i <= n; i++)
    {
        if ((i % 3 != 0) && (i % 5 != 0))
        {
            sum += i;
        }
    }

    cout << sum << endl;

    return 0;
}