#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  char dp[n][n];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> dp[i][j];
    }
  }
  int count = 0;
  for (int i = 1; i < n - 1; i++) {
    for (int j = 1; j < n - 1; j++) {
      if (dp[i][j] == 'X') {
        if (dp[i][j] == dp[i - 1][j - 1] && dp[i][j] == dp[i - 1][j + 1] &&
            dp[i][j] == dp[i + 1][j - 1] && dp[i][j] == dp[i + 1][j + 1]) {
          count++;
        }
      }
    }
  }
  cout << count << endl;
  return 0;
}
