#define N   6

void Row(int y);

int Counter;
int Solution[N];
int ListElement[1000][N];

void CheckUniqueSolution(void)
{
  int i,j,s;
  int chk[7];
  
  for(j=0; j<Counter; j++)
  {
    for(i=0;i<7;i++) chk[i]=0;
    for(i=0; i<N; i++)
    {
      s=Solution[i];
      if(s==ListElement[j][N-1-i]) chk[0]++;
      if(N-1-s==ListElement[j][i]) chk[1]++;
      if(N-1-s==ListElement[j][N-1-i]) chk[2]++;
      if(i==ListElement[j][s]) chk[3]++;
      if(i==ListElement[j][N-1-s]) chk[4]++;
      if(N-1-i==ListElement[j][s]) chk[5]++;
      if(N-1-i==ListElement[j][N-1-s]) chk[6]++;
    }
    for(i=0;i<7;i++) if(chk[i]==N) return;
  }
  for(i=0;i<N;i++)ListElement[Counter][i]=Solution[i];
  Counter++;
}

int Check(int x, int y)
{
  int i;
  
    for(i=0; i<N; i++) if(Solution[i]>=0)
    {
      if(Solution[i]==x) return 0;
      if((i==y-2)||(i==y+2))if((Solution[i]==x-1)||(Solution[i]==x+1))return 0;
      if((i==y-1)||(i==y+1))if((Solution[i]==x-2)||(Solution[i]==x+2))return 0;
    }
    return 1;
}

void Row(int y)
{
    int i, z;
    
    for(i=0; i<N; i++)
    {
      for(z=y; z<N; z++) Solution[z]=-1;
      if(Check(i,y))
      {
        Solution[y]=i;
        if(y==N-1) CheckUniqueSolution();
        else Row(y+1);
      }
    }
}

int main(void)
{
    Counter=0;
    Row(0);
    printf("\n%d", Counter);
    return 0;
}