#include <stdio.h>
#include <string.h>

int main(){

	long int  i,j;
	long int 	x,y,a,b,c;
	long int N,M,A[110];
	long long sum=0;
	scanf("%ld",&N);
	
	for(i=0;i<N;i++){
		if(i%3==0||i%5==0){
		}
		else {
			
			sum += (long long)i;
		}
	}
	
	printf("%lld\n",sum);
}