#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  return (b == 0 ? a : gcd(b, a % b));
}
long long int max(long long int a, long long int b) {
  if (a >= b) return a;
  return b;
}
long long int min(long long int a, long long int b) {
  if (a <= b) return a;
  return b;
}
void swap(long long int a, long long int b) {
  long long int t = a;
  a = b;
  b = t;
}
int main() {
  long long int n, cnt = 0;
  cin >> n;
  vector<vector<char>> A(n, vector<char>(n));
  for (long long int i = 0; i < n; i++) {
    for (long long int j = 0; j < n; j++) {
      cin >> A[i][j];
    }
  }
  for (long long int i = 1; i < n - 1; i++) {
    for (long long int j = 1; j < n - 1; j++) {
      if (A[i][j] == 'X' && A[i - 1][j - 1] == 'X' && A[i - 1][j + 1] == 'X' &&
          A[i + 1][j - 1] == 'X' && A[i + 1][j + 1] == 'X') {
        cnt++;
      }
    }
  }
  cout << cnt << endl;
}
