#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll ans,n;
int main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;++i)
		if(i%3!=0&&i%5!=0)
			ans+=ll(i);
	printf("%lld",ans);
	return 0; 
}