#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b, d, e, i, j, n, ans = 0;
  string s, s1;
  char c[1000][1000];
  map<long long, long long> m;
  vector<long long> v;
  cin >> n;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++) {
      cin >> c[i][j];
    }
  }
  for (i = 2; i <= n; i++) {
    for (j = 2; j <= n; j++) {
      if (c[i][j] == 'X' && c[i - 1][j - 1] == 'X' && c[i - 1][j + 1] == 'X' &&
          c[i + 1][j + 1] == 'X' && c[i + 1][j - 1] == 'X')
        ans++;
    }
  }
  cout << ans;
}
