#include<stdio.h>

int main(){
  
  	long int N, summ, i;
  	i = 1;
  	summ = 0;
  
  	scanf("%ld", &N);
  
  	while(i <= N){
    	if (i%3!=0&&i%5!=0){
          summ += i;
        }
      	i++;
    }
  
  	printf("%ld", summ);
  return 0;
}