#include<stdio.h>

int main()
{
	unsigned long j = 0, i, n;
	scanf("%lu", &n);
	int flag = 0;
	
	for (i = 1; i <= n; i++) {
		if (i % 3 != 0 && i % 5 != 0)
			j += i;
	}
	printf("%lu", j);
	return 0;
}