#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<string> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  int ans = 0;
  for (int i = 1; i < n - 1; i++) {
    for (int j = 1; j < n - 1; j++) {
      if (a[i][j] == 'X') {
        if (a[i - 1][j - 1] == 'X' && a[i - 1][j + 1] == 'X' &&
            a[i + 1][j + 1] == 'X' && a[i + 1][j - 1] == 'X')
          ans++;
      }
    }
  }
  cout << ans << endl;
}
