#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  char grid[n][n];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> grid[i][j];
    }
  }
  int out = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == 0 or i == n - 1 or j == 0 or j == n - 1)
        continue;
      else if (grid[i][j] == 'X' and grid[i - 1][j - 1] == 'X' and
               grid[i - 1][j + 1] == 'X' and grid[i + 1][j - 1] == 'X' and
               grid[i + 1][j + 1] == 'X')
        out++;
    }
  }
  cout << out;
  return 0;
}
