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

