#include <bits/stdc++.h>
using namespace std;
int main() {
  char a[505][505];
  int i, n, j, c = 0;
  cin >> n;
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      cin >> a[i][j];
    }
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      if (a[i][j] == 'X') {
        int m = i - 1;
        int n = i + 1;
        int o = j - 1;
        int p = j + 1;
        if (a[m][o] == 'X' && a[m][p] == 'X' && a[n][o] == 'X' &&
            a[n][p] == 'X') {
          c++;
        }
      }
    }
  }
  cout << c << endl;
  return 0;
}
