#include<stdio.h>

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