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