#include <stdio.h>

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

  scanf("%d", &N);

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

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

  return 0;
}