#include <stdio.h>
#include <math.h>
int main(int argc, char const *argv[])
{
  int n;
  int th,fi,fif;
  int a;
  scanf("%d",&n);
  th=n/3; fi=n/5; fif=n/15;
  th=3*th*(th+1)/2;
  fi=5*fi*(fi+1)/2;
  fif=15*fif*(fif+1)/2;
  a=n*(n+1)/2-th-fi+fif;
  printf("%d",a);
  return 0;
}