#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MAX(a, b) ((a) > (b) ? (a) : (b))
int main(void)
{
long long N, index, sum;

  scanf("%lld", &N);
  sum = 0;
  for (index = 1; index <= N; ++index) {
    if (index % 3 == 0) continue;
    if (index % 5 == 0) continue;
    sum += index;
  }
  printf("%lld\n", sum);
    
  return 0;
}
