#include <stdio.h>

int main(void)
{
  int i;
  long long sum;
  int n;

  i = 0;
  sum = 0;
  scanf("%d", &n);
  while (++i <= n)
  {
    if (i % 3 == 0)
      continue;
    if (i % 5 == 0)
      continue;
    sum += i;
  }
  printf("%lld\n", sum);
  return (0);
}