#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  char a[n + 5][n + 5];
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) cin >> a[i][j];
  long long k = 0;
  for (int i = 2; i < n; i++) {
    for (int j = 2; j < n; j++) {
      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' && a[i][j] == 'X')
        k++;
    }
  }
  cout << k;
  return 0;
}
