#include<stdio.h>

int main(void){
	long long i, N, SUM;

	scanf("%lld", &N);
	SUM = 0;

	for(i = 0; i <= N; i++){
		if(i % 3 == 0||i % 5 == 0)
			SUM = SUM;
		else
			SUM = SUM + i;
		
	}

	printf("%lld", SUM);

	return 0;

}