#include <bits/stdc++.h>
using namespace std;
long long prime[10000001] = {0};
int GCD(int A, int B) {
  int m = min(A, B), gcd;
  for (int i = m; i > 0; --i)
    if (A % i == 0 && B % i == 0) {
      gcd = i;
      return gcd;
    }
}
long long count_one(long long n) {
  long long count1 = 0;
  while (n) {
    n = n & (n - 1);
    count1++;
  }
  return count1;
}
char aa[501][501];
int main() {
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= n; j++) cin >> aa[i][j];
  }
  long long count2 = 0;
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= n; j++) {
      if (i < n && i > 1 && j < n && j > 1) {
        long long count1 = 0;
        if (aa[i][j] == 'X') {
          if (aa[i - 1][j - 1] == 'X') count1++;
          if (aa[i - 1][j + 1] == 'X') count1++;
          if (aa[i + 1][j - 1] == 'X') count1++;
          if (aa[i + 1][j + 1] == 'X') count1++;
        }
        if (count1 >= 4) {
          count2++;
        }
      }
    }
  }
  printf("%lld\n", count2);
}
