#include <stdio.h>

int main(void){
  unsigned int i;
  unsigned long int sum = 0;
  unsigned int input;
  
  scanf("%u",&input);
  for(i = 1;i <= input;i++){
    if((i % 3 != 0) && (i % 5 != 0)){
      sum += i;
    }
  }
  printf("%lu",sum);
}
