#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<vector<char>> info(n, vector<char>(n));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      char c;
      cin >> c;
      info[i][j] = c;
    }
  }
  int cont = 0;
  for (int i = 1; i < n - 1; i++) {
    for (int j = 1; j < n - 1; j++) {
      if (info[i][j] == 'X' && info[i - 1][j - 1] == 'X' &&
          info[i + 1][j + 1] == 'X' && info[i - 1][j + 1] == 'X' &&
          info[i + 1][j - 1] == 'X')
        cont++;
    }
  }
  cout << cont << '\n';
  return 0;
}
