#include <bits/stdc++.h>
using namespace std;
long long modpow(long long base, long long exp, long long modulus) {
  base %= modulus;
  long long result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}
int main() {
  int n;
  cin >> n;
  char a[n][n];
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < n; j++) {
      cin >> a[i][j];
    }
  }
  int c = 0;
  for (long long i = 1; i < n - 1; i++) {
    for (long long j = 1; j < n - 1; j++) {
      if (a[i - 1][j - 1] == 'X' && a[i - 1][j + 1] == 'X' &&
          a[i + 1][j - 1] == 'X' && a[i + 1][j + 1] == 'X' && a[i][j] == 'X')
        c++;
    }
  }
  cout << c;
  return 0;
}
