#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define _ << ' ' <<
using namespace std;
using ll = long long;


int main()
{
    ll n;
    cin >> n;
    ll sol = 0;
    for (int i = 1; i <= n; ++i)
        if (i % 3 && i % 5)
            sol += i;
    cout << sol;
}
