#include <bits/stdc++.h>

using namespace std;

#define endl '\n'
#define ll long long

const ll mod = 1e9 + 7;
const ll maxn = 2e8 + 5;
const double pi = 3.1415926535897932384626433832795028841971693993751058209749445923078;
//iostream::sync_with_stdio(false);

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