#include <stdio.h>

int main(void) {
	int N;
	long sum = 0;
	
	scanf("%d", &N);
	
	for(int i = 1; i <= N; i++) {
		if(i % 3 == 0)	continue;
		if(i % 5 == 0)	continue;
		sum += i;
	}
	
	printf("%ld\n", sum);
	
	return 0;
}
