#include<bits/stdc++.h>
#define  ll   long long int
#define  sz   200010

using namespace std;


int main()
{



    ll s=0;

    ll i,j,n;

    cin>>n;

    for(i=1;i<=n;i++)
    {
        if(i%3!=0 && i%5!=0)
        {
            s+=i;
        }
    }

    cout<<s<<endl;

    return 0;
}

