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