#include <stdio.h>

int main (){
  long int N,Fizz, Buzz, FizzBuzz, sum;
  scanf("%d",&N);
  Fizz = 3*(N/3)*(N/3 + 1)/2;
  Buzz = 5* (N/5)*(N/5 + 1)/2;
  FizzBuzz = 15 * (N/15) * (N/15 + 1)/2;
  sum = N*(N+1)/2-Fizz-Buzz+FizzBuzz;
  printf("%d",sum);
  return 0;
}
