#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, j, k;
  cin >> n;
  char a[n + 1][n + 1];
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++) {
      cin >> a[i][j];
    }
  }
  int ans = 0;
  for (i = 2; i < n; i++) {
    for (j = 2; j < n; j++) {
      if (a[i][j] == 'X') {
        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')
          ans++;
      }
    }
  }
  cout << ans;
}
