#include <stdio.h>

int main(void){

  long n;
  scanf("%ld", &n);
  long sum = 0;
  for (long i = 1; i <= n; i++) {
    if (i % 3 != 0 && i % 5 != 0) {
      sum += i;
    }
  }
  printf("%ld\n", sum);

  return 0;
}