#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  char a[n + 1][n + 1];
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      cin >> a[i][j];
    }
  }
  if (n < 3) {
    cout << "0";
    return 0;
  }
  int c = 0;
  int x, y;
  for (int i = 2; i <= n - 1; i++) {
    for (int j = 2; j <= n - 1; j++) {
      if (a[i][j] == 'X' && a[i + 1][j + 1] == 'X' && a[i + 1][j - 1] == 'X' &&
          a[i - 1][j + 1] == 'X' && a[i - 1][j - 1] == 'X' &&
          (x != i || y != j)) {
        x = i;
        y = j;
        c++;
      }
    }
  }
  cout << c;
  return 0;
}
