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