#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  long long int n;
  cin >> n;
  char grid[n + 2][n + 2];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> grid[i][j];
    }
  }
  long long int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (grid[i][j] == 'X' && grid[i - 1][j - 1] == 'X' &&
          grid[i - 1][j + 1] == 'X' && grid[i + 1][j - 1] == 'X' &&
          grid[i + 1][j + 1] == 'X')
        ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
