#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  map<int, int> mpi;
  map<int, int> mpj;
  char M[n][n];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> M[i][j];
    }
  }
  int c = 0;
  for (int i = 1; i < n - 1; i++) {
    for (int j = 1; j < n - 1; j++) {
      if (M[i][j] != '.' && M[i][j] == M[i - 1][j - 1] &&
          M[i - 1][j - 1] == M[i - 1][j + 1] &&
          M[i - 1][j + 1] == M[i + 1][j - 1] &&
          M[i + 1][j - 1] == M[i + 1][j + 1]) {
        c++;
        mpi[i] = 1;
        mpj[j] = 1;
      }
    }
  }
  cout << c << endl;
  return 0;
}
