#include <bits/stdc++.h>
using namespace std;
char c[505][505];
int jud(int i, int j) {
  if (c[i][j] == '.') return 0;
  if (c[i - 1][j - 1] == '.') return 0;
  if (c[i - 1][j + 1] == '.') return 0;
  if (c[i + 1][j - 1] == '.') return 0;
  if (c[i + 1][j + 1] == '.') return 0;
  if (c[i][j] != c[i - 1][j - 1]) return 0;
  if (c[i][j] != c[i - 1][j + 1]) return 0;
  if (c[i][j] != c[i + 1][j - 1]) return 0;
  if (c[i][j] != c[i + 1][j + 1]) return 0;
  return 1;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> c[i][j];
    }
  }
  int cnt = 0;
  for (int i = 1; i < n - 1; i++) {
    for (int j = 1; j < n - 1; j++) {
      if (jud(i, j) == 1) cnt++;
    }
  }
  printf("%d\n", cnt);
  return 0;
}
