#include <bits/stdc++.h>
int main() {
  char a[505][505], p;
  int n, m, k;
  scanf("%d", &n);
  getchar();
  for (k = 1; k <= n; k++) {
    for (m = 1; m <= n; m++) {
      scanf("%c", &a[k][m]);
    }
    getchar();
  }
  int sum = 0;
  for (k = 1; k <= n - 2; k++) {
    for (m = 1; m <= n - 2; m++) {
      if (a[k][m] == 'X') {
        if (a[k + 2][m] == 'X' && a[k + 1][m + 1] == 'X' &&
            a[k + 2][m + 2] == 'X' && a[k][m + 2] == 'X')
          sum++;
      }
    }
  }
  printf("%d\n", sum);
}
