#include <stdio.h>
int main(){
  int N,fizz,buzz,fizzbuzz,sum;
  scanf("%d",&N);
  fizz=N/3;
  buzz=N/5;
  fizzbuzz=N/15;
  sum=N*(N+1)/2-fizz*(6+3*(fizz-1))/2-buzz*(10+5(buzz-1))/2+fizzbuzz*(30+15(fizzbuzz-1))/2;
  printf("%d",sum);
  return 0;
}