#include <iostream>

using namespace std;

typedef long long ll;

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