#include <stdio.h>
#include <math.h>
int area[13], count = 0;
int cek(int row, int column)
{
    int i;
    for (i = 1; i <= row - 1; ++i)
    {
        if (area[i] == column)
            return 0;
        else if (abs(area[i] - column) == abs(i - row))
            return 0;
    }
    return 1;
}
void bomb(int row, int n)
{
    int column = 0;
    for (column = 1; column <= n; ++column)
    {
        if (cek(row, column))
        {
            area[row] = column;
            if (row == n)
                ++count;
            else
                bomb(row + 1, n);
        }
    }
}
int main()
{
    int n;
    scanf("%d", &n);
    bomb(1, n);
    printf("%d", count);
    return 0;
}