#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  bool a[505][505];
  memset(a, false, sizeof(a));
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      char x;
      cin >> x;
      if (x == 'X')
        a[i][j] = true;
      else
        a[i][j] = false;
    }
  }
  if (n <= 2) {
    cout << 0 << endl;
    return 0;
  }
  int ans = 0;
  for (int i = 2; i < n; i++) {
    for (int j = 2; j < n; j++) {
      if (a[i][j] && a[i + 1][j + 1] && a[i + 1][j - 1] && a[i - 1][j + 1] &&
          a[i - 1][j - 1]) {
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
