#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  int n;
  cin >> n;
  char m[n][n];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) cin >> m[i][j];
  }
  int ans = 0;
  for (int i = 1; i < n - 1; i++) {
    for (int j = 1; j < n - 1; j++) {
      if (m[i][j] == 'X' and m[i - 1][j - 1] == 'X' and
          m[i - 1][j + 1] == 'X' and m[i + 1][j - 1] == 'X' and
          m[i + 1][j + 1] == 'X')
        ans++;
    }
  }
  cout << ans << endl;
  cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
  return 0;
}
