#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int i, j, n;
  cin >> n;
  char arr[n][n];
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      cin >> arr[i][j];
    }
  }
  int count = 0;
  for (i = 1; i < (n - 1); i++) {
    for (j = 1; j < (n - 1); j++) {
      if ((arr[i][j] == 'X') && (arr[i - 1][j - 1] == 'X') &&
          (arr[i - 1][j + 1] == 'X') && (arr[i + 1][j - 1] == 'X') &&
          (arr[i + 1][j + 1] == 'X'))
        count++;
    }
  }
  cout << count;
}
