#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int count = 0, i, j, n;
  cin >> n;
  string s[1000];
  for (i = 0; i < n; i++) cin >> s[i];
  for (i = 1; i < n - 1; i++) {
    for (j = 1; j < n - 1; j++) {
      if (s[i][j] == 'X') {
        if (s[i - 1][j - 1] == 'X') {
          if (s[i - 1][j + 1] == 'X') {
            if (s[i + 1][j - 1] == 'X') {
              if (s[i + 1][j + 1] == 'X') count++;
            }
          }
        }
      }
    }
  }
  cout << count << "\n";
}
