#include <bits/stdc++.h>
int n, cnt;
char a[505][505];
inline bool change(int x, int y) {
  if (a[x - 1][y - 1] == 'X' && a[x - 1][y + 1] == 'X' &&
      a[x + 1][y - 1] == 'X' && a[x + 1][y + 1] == 'X')
    return true;
  return false;
}
int main() {
  scanf("%d\n", &n);
  for (register int i = 1; i <= n; i++) {
    for (register int j = 1; j <= n; j++) scanf("%c", &a[i][j]);
    scanf("\n");
  }
  for (register int i = 2; i < n; i++)
    for (register int j = 2; j < n; j++)
      if (a[i][j] == 'X' && change(i, j)) cnt++;
  printf("%d", cnt);
}
