#include <bits/stdc++.h>
using namespace std;

void solve()
{
    long long n;
    cin>>n;
    long long  sum = 0;
    for(long long i=1;i<=n;i++)
    {
        if(i%3==0||i%5==0)continue;
        else
        sum +=i;
    }
    cout<<sum<<endl;
}

int main()
{
    int t;
    t=1;
    while(t--)
        solve();
}
