#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>



int main() {
  unsigned long long i, j = 0, k, num = 0,  ans = 0, N = 0;
  scanf("%llu", &N);
  num = N;
  for (i = 1; i <= N; i++) {
    if (i % 3 != 0 && i % 5 != 0) ans += i;
  }
  printf("%llu", ans);
  return 0;
}
