#include <stdio.h>

int main(int argc, char const *argv[]) {

  long long int N;
  scanf("%lld", &N);

  long long int F, B, FB;
  F = N / 3;
  B = N / 5;
  FB = N / 15;

  long long int sum = N * (1 + N) / 2;
  sum = sum - ((3 + 3 * F) * F / 2) - ((5 + 5 * B) * B / 2) + (((15 + 15 * FB) * FB / 2));

  printf("%lld\n", sum);

  long long int A;
  return 0;
}
