import java.util.Arrays;

class NQueens {
    static int N, count;
    static int[] column;
    
    public static void main (String[] args) {
        N = 14;
        column = new int[N];
        nQueens(0);
        System.out.println(count);
    }
        
    private static void nQueens(int row) {
        if (row == N) {
            // System.out.println(Arrays.toString(column));
            count++;
            return;
        }
        for (int col = 0; col < N; col++) {
            if (place(row, col)) {
                column[row] = col;
                nQueens(row + 1);
            }
        }
    }
        
    private static boolean place(int row, int col) {
        for (int i = 0; i < row; i++) {
            if (column[i] == col || Math.abs(column[i] - col) == Math.abs(i - row)) {
                return false;
            }
        }
        return true;
    }
}