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

int main()
{
    unsigned long long n;
    cin>>n;
    unsigned long sum=0;
    for(unsigned long long i=1;i<=n;i++)
    {
	if(i%3==0 && i%5==0)
	    {
	    
	    }
	else if(i%3==0)
	    {
	    
	    
	    }
	else if(i%5==0)
	    {
	    
	    
	    }
	else
	{
	    sum+=i;
	}
    }


    cout<<sum;
    
    
    return 0;
}
