#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 515;
char mp[MAX_N][MAX_N];
vector<pair<int, int> > vt;
int main() {
  int n, ans = 0;
  scanf("%d", &n);
  getchar();
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      scanf("%c", &mp[i][j]);
      if (mp[i][j] == 'X') {
        vt.push_back(make_pair(i, j));
      }
    }
    getchar();
  }
  int sz = vt.size();
  for (int i = 0; i < sz; ++i) {
    int x = vt[i].first;
    int y = vt[i].second;
    if (x - 1 >= 1 && y - 1 >= 1 && mp[x - 1][y - 1] == 'X' && y + 1 <= n &&
        mp[x - 1][y + 1] == 'X' && x + 1 <= n && mp[x + 1][y - 1] == 'X' &&
        y + 1 <= n && mp[x + 1][y + 1] == 'X')
      ans++;
  }
  printf("%d\n", ans);
  return 0;
}
