#include <stdio.h>

int main(void)
{
	int i;
	int j;
	long sum;

	scanf("%d", &i);
	sum = 0;
	j = 1;
	while (j <= i)
	{
		if ((j % 3 != 0) && (j % 5 != 0))
			sum += j;
		j++;
	}
	printf("%ld\n", sum);
	return (0);
} 
