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