#include <bits/stdc++.h>
using namespace std;
const int MAXN = 510;
int n;
char game[MAXN][MAXN];
inline bool c(int x, int y) {
  if (x > n || x <= 0 || y > n || y <= 0) return false;
  return game[x][y] == 'X';
}
inline bool check(int x, int y) {
  if (c(x - 1, y - 1) && c(x - 1, y + 1) && c(x + 1, y - 1) && c(x + 1, y + 1))
    return true;
  return false;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      cin >> game[i][j];
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (c(i, j) && check(i, j)) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
