#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e2 + 7;
char mp[maxn][maxn];
int main() {
  int ans = 0, n;
  cin >> n;
  for (int i = 0; i < n; i++) scanf("%s", mp[i]);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if (mp[i][j] == mp[j][i]) {
        if (i == j)
          for (int k = 0; k < n; k++)
            if (mp[k][k] == mp[i][j] && i != k)
              ans++;
            else
              ans++;
      }
  cout << ans << endl;
  return 0;
}
