#include <stdio.h>

int main(void)
{
  long int N;
  long int f, b, fb;
  long int sum;
  long int sumf, sumb, sumfb;

  scanf("%d", &N);

  f = N/3;
  b = N/5;
  fb = N/15;

  sumf = f*(f+1)/2*3;
  sumb = b*(b+1)/2*5;
  sumfb = fb*(fb+1)/2*15;
  
  sum = N*(N+1)/2 - sumf - sumb + sumfb;
  printf("%ld\n", sum);

  return 0;
}