#include<iostream>
using namespace std;
#define int long long int
int32_t main()
{
	int n;
	cin>>n;
	int answer=0;
	int j;
	for(j=1;j<=n;j++)
	{
		if(j%3!=0&&j%5!=0)
		{
			answer+=j;
		}
	}
	cout<<answer<<endl;
}
