#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t, i, j, k, l, m, n, a[200005], b[200005];
  char s[501][501];
  map<long long, long long> mp;
  pair<long long, long long> p[200005];
  cin >> n;
  for (i = 0; i < n; i++) scanf("%s", s[i]);
  int count = 0;
  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] == s[i][j] && s[i - 1][j + 1] == s[i][j] &&
            s[i + 1][j - 1] == s[i][j] && s[i + 1][j + 1] == s[i][j])
          count++;
      }
    }
  }
  cout << count;
  return 0;
}
