#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
bool Debug = true;
ll maxn(vector<ll>& h) {
  ll ans = -1e18;
  for (int ijkl = 0; ijkl < h.size(); ++ijkl) {
    ans = max(ans, (ll)h[ijkl]);
  }
  return ans;
}
ll minn(vector<ll>& h) {
  ll ans = 1e18;
  for (int ijkl = 0; ijkl < h.size(); ++ijkl) {
    ans = min(ans, (ll)h[ijkl]);
  }
  return ans;
}
ll sumn(vector<ll>& h) {
  ll ans = 0;
  for (int ijkl = 0; ijkl < h.size(); ++ijkl) {
    ans += h[ijkl];
  }
  return ans;
}
ll pown(ll n, ll cnt) {
  if (cnt == 0) {
    return 1;
  }
  if (cnt == 1) {
    return n;
  }
  if (cnt % 2 == 0) {
    ll a = pown(n, cnt / 2);
    return (a * a);
  } else {
    ll a = pown(n, (cnt - 1) / 2);
    return (a * a) * n;
  }
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
struct Point {
  int x, y;
  Point() : x(0), y(0) {}
  Point(int _x, int _y) : x(_x), y(_y) {}
  Point(Point a, Point b) : x(b.x - a.x), y(b.y - a.y) {}
};
string alph = "abcdefghijklmnopqrstuvwxyz";
vector<vector<pair<ll, ll> > > g;
vector<ll> dist, w;
vector<ll> ans, dp;
void dfs(int v, ll cnt) {
  dist[v] = cnt;
  for (auto i : g[v]) {
    if (dist[i.first] == -1) {
      dfs(i.first, cnt);
    }
  }
  ans.push_back(v);
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ll n;
  cin >> n;
  ll cnt = 0;
  vector<string> h(n);
  for (ll ijkl = 0; ijkl < n; ++ijkl) cin >> h[ijkl];
  for (int i = 1; i < n - 1; ++i) {
    for (int j = 1; j < n - 1; ++j) {
      if (h[i][j] == h[i - 1][j - 1] && h[i][j] == h[i + 1][j + 1] &&
          h[i][j] == h[i + 1][j - 1] && h[i][j] == h[i - 1][j + 1] &&
          h[i][j] == 'X') {
        ++cnt;
      }
    }
  }
  cout << cnt;
  return 0;
}
