#include<stdio.h>
int main()
{
  long N,i,wa,wa0;
  scanf("%ld",&N);
  wa=0;
  wa0=0;
  for(i=1;i<=N;i++)
  {
    if(i%3==0||i%5==0)
    {
      wa0=wa0+i;
    }
    else if(i%3==0&&i%5==0)
    {
      wa0=wa0+i;
    }
    wa=wa+i;
  }
    printf("%ld",wa-wa0);
}