#include <bits/stdc++.h>
using namespace std;
long long max(long long a, long long b) {
  if (a > b)
    return a;
  else
    return b;
}
long long min(long long a, long long b) {
  if (a < b)
    return a;
  else
    return b;
}
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long lcm(long long a, long long b) {
  return (max(a, b) / gcd(a, b)) * min(a, b);
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  srand(time(NULL));
  long long 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];
  long long cnt = 0;
  if (n <= 2) {
    cout << 0 << endl;
    return 0;
  }
  for (long long i = 1; i <= n - 2; i++) {
    for (long long j = 1; j <= n - 2; 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;
  return 0;
}
