#include <stdio.h>

int main()
{
  int num = 0;
  long long seq = 0;
  
  while(num<1 || num>1000000)
    scanf("%d",&num);
  
  for(int i=0; i<num; ++i)
  {
    if((i%3)!=0 && (i%5)!=0)
      seq+=i;
  }
  
  printf("%lld", seq);
  
  return 0;
}