#include<stdio.h>

int main(void){
  int N = 0;
  long sum =0;

  scanf("%d\n",&N);
  for(int i =1;i<(N+1);i++){
    if((i%3!=0) && (i%5!=0)){
      sum += i;
    }
  }
  printf("%ld\n",sum);
  return 0;
}