#include <bits/stdc++.h>
using namespace std;
void fast() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}
char A[1005][1005];
void solve() {
  memset(A, 0, sizeof(A));
  int n;
  cin >> n;
  for (long long int i = 0; i < n; i++) {
    for (long long int j = 0; j < n; j++) cin >> A[i][j];
  }
  int cc = 0;
  for (long long int i = 0; i < n; i++) {
    for (long long int j = 0; j < n; j++) {
      if (A[i][j] == A[i - 1][j - 1] && A[i][j] == A[i - 1][j + 1] &&
          A[i][j] == A[i + 1][j - 1] && A[i][j] == A[i + 1][j + 1] &&
          A[i][j] == 'X')
        cc++;
    }
  }
  cout << cc << "\n";
}
int main() {
  int T = 1;
  while (T--) {
    solve();
  }
  return 0;
}
