#include <bits/stdc++.h>
using namespace std;

const auto MAXN = 305;
const auto bas = 19260817ull;
typedef unsigned long long ull;
int n, a[MAXN][MAXN];
ull c[MAXN][MAXN], d[MAXN][MAXN];

auto init = [&]() {
	auto x = 1ull;
	for (auto i = 1; i <= n; i++)
		for (auto j = 1; j <= n; j++) {
			c[i][j] = a[i][j]*x+c[i-1][j]+c[i][j-1]-c[i-1][j-1];
			x *= bas;
		}
	x = 1;
	for (auto j = 1; j <= n; j++)
		for (auto i = 1; i <= n; i++) {
			d[i][j] = a[i][j]*x+d[i-1][j]+d[i][j-1]-d[i-1][j-1];
			x *= bas;
		}
};

auto query = [](ull a[MAXN][MAXN], int x1, int x2, int y1, int y2) {
	return a[x2][y2]-a[x1-1][y2]-a[x2][y1-1]+a[x1-1][y1-1];
};

ull power[MAXN*MAXN*2];

int main()
{
	ios::sync_with_stdio(false);
	cin >> n;
	for (auto i = 1; i <= n; i++) {
		string str;
		cin >> str;
		for (auto j = 1; j <= n; j++)
			a[i][j] = str[j-1];
	}
	init();
	power[0] = 1;
	for (register int i = 1; i <= n*n+n; i++)
		power[i] = power[i-1]*bas;
	int ans = 0;
	for (auto A = 1; A <= n; A++) {
		for (auto B = 1; B <= n; B++) {
			// cerr << a[A][B] << " ";
			auto curx = query(c, 1, A, 1, B)*power[n*n+n]+query(c, A+1, n, 1, B)*power[n]+query(c, 1, A, B+1, n)*power[n*n]+query(c, A+1, n, B+1, n);
			auto cury = query(d, 1, A, 1, B)*power[n*n+n]+query(d, A+1, n, 1, B)*power[n*n]+query(d, 1, A, B+1, n)*power[n]+query(d, A+1, n, B+1, n);
			curx *= power[(n-A)*n+(n-B)], cury *= power[(n-B)*n+(n-A)];
			// cerr << curx << " " << cury << endl;
			if (curx == cury)
				ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

