#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = double;
using pll = pair<ll, ll>;
using vll = vector<ll>;
using vpll = vector<pll>;
using vvll = vector<vll>;
char mtx[510][510];
int main() {
  ios::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  ll n;
  cin >> n;
  for (ll i = 0; i < (ll)n; ++i) {
    for (ll j = 0; j < (ll)n; ++j) {
      cin >> mtx[i][j];
    }
  }
  ll res = 0;
  for (int i = 1; i < n - 1; ++i) {
    for (int j = 1; j < n - 1; ++j) {
      if (mtx[i][j] == mtx[i - 1][j - 1] && mtx[i][j] == mtx[i - 1][j + 1] &&
          mtx[i][j] == mtx[i + 1][j - 1] && mtx[i][j] == mtx[i + 1][j + 1] &&
          mtx[i][j] == 'X') {
        res++;
      }
    }
  }
  cout << res << endl;
  return 0;
}
