#include<stdio.h>
//#define scanf scanf_s
int main()
{
	int n, i;
	long long sum=0;
	scanf("%d", &n);
	for (i = 1; i <= n; i++)
	{
		if (i % 3 != 0 && i % 5 != 0)
			sum += i;
	}
	printf("%lld", sum);
}