// Arup Guha
// 5/8/2018
// Solution to USACO 2015 US Open Bronze Problem: Palindromic Paths

import java.util.*;
import java.io.*;

public class palpath {

	public static void main(String[] args) throws Exception {

		// Read in data.
		Scanner stdin = new Scanner(new File("palpath.in"));
		int n = stdin.nextInt();
		char[][] grid = new char[n][];
		for (int i=0; i<n; i++)
			grid[i] = stdin.next().toCharArray();

		// Easier so I can use the same method do analyze my strings.
		char[][] flip = new char[n][n];
		for (int i=0; i<n; i++)
			for (int j=0; j<n; j++)
				flip[i][j] = grid[n-1-i][n-1-j];

		// Form all possible strings from top left corner to middle line.
		HashSet<String> reg = new HashSet<String>();
		getStrings(grid, ""+grid[0][0], 0, 0, reg, true);

		// Form all possible strings backwards from bottom right corner to middle line.
		HashSet<String> back = new HashSet<String>();
		getStrings(flip, ""+flip[0][0], 0, 0, back, false);

		// Number of matches is the number of unique palindromes.
		HashSet<String> actual = new HashSet<String>();
		int res = 0;
		for (String s: reg) {
			String strip = s.substring(0, s.length()-1);
			if (back.contains(s) && !actual.contains(strip)) {
				res++;
				actual.add(strip);
			}
		}

		// Write result.
		PrintWriter out = new PrintWriter(new FileWriter("palpath.out"));
		out.println(res);
		out.close();
		stdin.close();
	}

	public static void getStrings(char[][] g, String cur, int x, int y, HashSet<String> list, boolean mode) {

		// We finished a string.
		if (cur.length() == g.length) {
			char add = mode ? (char)('A'+x) : (char)('A'+y);
			list.add(cur+add);
			return;
		}

		// Go down, then right.
		getStrings(g, cur+g[x+1][y], x+1, y, list, mode);
		getStrings(g, cur+g[x][y+1], x, y+1, list, mode);
	}
}