#include <bits/stdc++.h>
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n;
  std::cin >> n;
  std::vector<std::string> M(n);
  for (int i = 0; i < n; ++i) {
    std::cin >> M[i];
  }
  int cross_counter = 0;
  for (int i = 1; i < n - 1; ++i) {
    for (int j = 1; j < n - 1; ++j) {
      if (M[i][j] == 'X' && M[i - 1][j - 1] == 'X' && M[i - 1][j + 1] == 'X' &&
          M[i + 1][j - 1] == 'X' && M[i + 1][j + 1] == 'X') {
        ++cross_counter;
      }
    }
  }
  std::cout << cross_counter << std::endl;
  return 0;
}
