#include <bits/stdc++.h>
int main(int argc, char const *argv[]) {
  int n, c = 0;
  char s[501][501];
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%s", &s[i]);
  }
  for (int i = 1; i < n - 1; i++) {
    for (int j = 1; j < n - 1; j++) {
      if ((s[i][j] == 'X') && (s[i - 1][j - 1] == 'X') &&
          (s[i - 1][j + 1] == 'X') && (s[i + 1][j - 1] == 'X') &&
          (s[i + 1][j + 1] == 'X')) {
        c++;
      }
    }
  }
  printf("%d", c);
  return 0;
}
