#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
using ll = long long;
using P = pair<int, int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double eps = 1e-9;
constexpr ll mod = 998244353;
const int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<string> G(N);
  for (int i = 0; i < N; i++) cin >> G[i];
  int ans = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (G[i][j] != 'X') continue;
      bool can = true;
      for (int k = 4; k < 8; k++) {
        int y = i + dy[k];
        int x = j + dx[k];
        if (y < 0 || y >= N || x < 0 || x >= N) {
          can = false;
          continue;
        }
        if (G[y][x] != 'X') can = false;
      }
      ans += can;
    }
  }
  cout << ans << "\n";
  return 0;
}
