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