#include<stdio.h>
int main(void){
  long int i;
  long int N;
  long int answer = 0;
  
  scanf("%ld", &N);
  for(i = 1; i <= N; i++) {
    if(i % 3 != 0 && i % 5 != 0) {
      answer += i;
    }
  }
  
  printf("%ld", answer);
  
  return 0;
}