#include <bits/stdc++.h>
using namespace std;
const int N = 550;
char s[N][N];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> s[i] + 1;
  int cn = 0;
  for (int i = 2; i < n; i++)
    for (int j = 2; j < n; j++) {
      if (s[i][j] == 'X' && s[i - 1][j - 1] == 'X' && s[i - 1][j + 1] == 'X' &&
          s[i + 1][j - 1] == 'X' && s[i + 1][j + 1] == 'X')
        cn++;
    }
  cout << cn << endl;
  return 0;
}
