#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
char str[505][505];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> str[i];
  int res = 0;
  for (int i = 1; i < n - 1; i++) {
    for (int j = 1; j < n - 1; j++) {
      if (str[i][j] == 'X' && str[i - 1][j - 1] == 'X' &&
          str[i - 1][j + 1] == 'X' && str[i + 1][j - 1] == 'X' &&
          str[i + 1][j + 1] == 'X')
        res++;
    }
  }
  cout << res << endl;
  return 0;
}
