#include <stdio.h>
#include <stdlib.h>
#include <string.h>

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