#include <bits/stdc++.h>
using namespace std;
const long double PI = 3.141592653589793238L;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  char arr[n + 10][n + 10];
  for (int i = 0; i < n; i++) cin >> arr[i];
  int count = 0;
  for (int i = 1; i < n - 1; i++) {
    for (int 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 << endl;
  return 0;
}
