#include <bits/stdc++.h>
#define pb push_back
#define int long long
using namespace std;

inline int read()
{
	int sum=0,ff=1; char ch=getchar();
	while(!isdigit(ch))
	{
		if(ch=='-') ff=-1;
		ch=getchar();
	}
	while(isdigit(ch))
		sum=sum*10+(ch^48),ch=getchar();
	return sum*ff;
}

int n,m;

signed main()
{
	n=read();
	for ( int i=1;i<=n;i++ )
	{
		if(i%3==0||i%5==0) continue;
		m+=i;
	}
	printf("%lld\n",m);
	return 0;
}