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