#include <stdio.h>

int main(){
	int N; //入力
	int i; //counter
	long long sum = 0; 

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