#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline long long int rand(long long int x, long long int y) {
  ++y;
  return (rng() % (y - x)) + x;
}
long long int n;
char grid[506][506];
long long int ans;
int main() {
  cin >> n;
  for (long long int i = 0; i < n; i++) {
    for (long long int j = 0; j < n; j++) cin >> grid[i][j];
  }
  for (long long int i = 1; i < n - 1; i++) {
    for (long long int j = 1; j < n - 1; 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 << "\n";
}
