#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int n;
long long sum;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		if(i%3==0||i%5==0)
		{
			continue;
		}
		sum+=i;
	}
	cout<<sum;
	return 0;
}