#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, ans = 0, x = 0;
  cin >> n;
  char arr[n][n];
  for (long long i = 0; i < n; i++) {
    for (long long g = 0; g < n; g++) {
      cin >> arr[i][g];
    }
  }
  for (long long i = 1; i < n - 1; i++) {
    for (long long j = 1; j < n - 1; j++) {
      if (arr[i][j] == 'X' && arr[i - 1][j + 1] == 'X' &&
          arr[i + 1][j - 1] == 'X' && arr[i + 1][j + 1] == 'X' &&
          arr[i - 1][j - 1] == 'X')
        ans++;
    }
  }
  cout << ans;
  return 0;
}
