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