#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, sum = 0;
  char ch[510][510];
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%s", ch[i]);
  if (n < 3)
    cout << 0 << endl;
  else {
    for (int i = 2; i < n; i++) {
      for (int j = 1; j < n - 1; j++) {
        if (ch[i][j] == 'X' && ch[i - 1][j - 1] == 'X' &&
            ch[i - 1][j + 1] == 'X' && ch[i + 1][j - 1] == 'X' &&
            ch[i + 1][j + 1] == 'X') {
          sum++;
        }
      }
    }
    cout << sum << endl;
  }
  return 0;
}
