#include <stdio.h>
 
int main(void){
  
  int N;
  char str[9];
  int i,sum;
  
  fgets(str,sizeof str,stdin);
  sscanf(str,"%d",&N);
  
  sum = 0;
  
  for(i = 1;i <= N;i++){
    
    if(i % 3 == 0){
      
      continue;
      
    }
    
    else if(i % 5 == 0){
      
      continue;
      
    }
    
    else{
      
      sum += i;
      
    }
    
  }
  
  printf("%d\n",sum);
  
  return 0;
  
}