#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  char X[600][600];
  int ANSWER = 0;
  for (int i = 0; i < N; i++) scanf("%s", &X[i]);
  for (int i = 1; i < N - 1; i++) {
    for (int j = 1; j < N - 1; j++)
      if (X[i][j] == X[i + 1][j + 1] && X[i][j] == X[i - 1][j - 1] &&
          X[i][j] == X[i - 1][j + 1] && X[i][j] == X[i + 1][j - 1] &&
          X[i][j] == 'X')
        ANSWER++;
  }
  printf("%d", ANSWER);
}
