# include<stdio.h>
void main()
{
  int n, i, s = 0;
  scanf("%d",&n);
  for(i=3;i<=n;i++)
  {
    if(((i%3) != 0) && ((i%5) != 0))
    {
        printf("%d\n",(i%3));
        printf("%d\n",(i%5));
      s = s + i;
    }
  }
  
  printf("%d",(s+3));
}