#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll a;
    cin>>a;
    ll i;
    ll s=0;
    for(i=1;i<=a;i++)
    {
        if(i%3!=0&&i%5!=0)
            s+=i;
    }
    cout<<s<<endl;
}
