#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;

int main(void)
{
	int n;
	scanf("%d",&n);
	ll ans=0;
	for(int i=1; i<=n; ++i)
	{
		if(i%3 && i%5) ans += i;
	}
	printf("%lld",ans);
	return 0;
}