#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  char s[1007][1007];
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      cin >> s[i][j];
    }
  }
  if (n < 3) {
    cout << "0";
  } else {
    int res = 0;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        if (s[i][j] == 'X' && s[i - 1][j + 1] == 'X' &&
            s[i + 1][j - 1] == 'X' && s[i - 1][j - 1] == 'X' &&
            s[i + 1][j + 1] == 'X') {
          res++;
        }
      }
    }
    cout << res;
  }
  return 0;
}
