#include<stdio.h>

int main(void){
  unsigned long long int n,tmp,three,five,fifteen;
  scanf("%llu",&n);
  
  tmp=(1+n)*n/2;
  three=n/3;
  five=n/5;
  fifteen=n/15;
  three=(1+three)*three/2*3;
  five=(1+five)*five/2*5;
  fifteen=(1+fifteen)*fifteen/2*15;
  printf("%llu",tmp-three-five+fifteen);
  return 0;
}