#include<stdio.h>

int main(void)
{
  unsigned long long int N,n,sum;
  sum = 0;
  N=0;
  //read
  scanf("%d",&N);
  //check
  for(n=1;n<=N;n++)
  {
  	if(n%3!=0&&n%5!=0)
  	{
  		sum = sum + n;
  	}
  }
  //write
  printf("%d",sum);
  return 0;
}