#include <stdio.h>

int main(void)
{

  long long int n, i, sum=0, not_sum=0;

  scanf("%lld", &n);

  if (n == 1) sum = 1;
  else if (n == 2) sum = 3;
  else if (n == 3) sum = 3;
  else if (n == 4) sum = 7;
  else  if (n >= 5 && n < 15) {
    not_sum += (3 + (n / 3) * 3) * (n / 3)/2;
    not_sum += (5 + (n / 5) * 5) * (n / 5)/2; 
    sum = (1+n)*n/2 - not_sum;
  } else {
    not_sum += (3 + (n / 3) * 3) * (n / 3)/2;
    not_sum += (5 + (n / 5) * 5) * (n / 5)/2; 
    not_sum -= (15 + (n / 15) * 15) * (n / 15)/2; 
    sum = (1+n)*n/2 - not_sum;
  }

  printf("%lld", sum);

  return 0;
}
