#include <stdio.h>
#include <math.h>
int main()
{
  long long int N;
  long long int thr;
  long long int fiv;
  long long int fif;
  long long int ans;
  scanf("%lld", &N);
  thr = N / 3;
  fiv = N / 5;
  fif = N / 15;
  ans = ( N * ( N + 1 ) - 3 * thr * ( thr + 1 ) - 5 * fiv * ( fiv + 1 )
         + 15 * fif * ( fif + 1 ) ) / 2;
  printf("%lld", ans);
  return 0;
}