#include <iostream>

using ll = long long;
using ull = unsigned long long;

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll N,sum=0;
    cin>>N;

    for(ll i = 1; i<=N; ++i)
    {
        if(i%3==0 or i%5==0)
            continue;
        else
        {
            sum+=i;
        }
        
    }
    cout<<sum<<'\n';
    return 0;
}
