#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int MAXN = 510;
char a[MAXN][MAXN];
inline int read() {
  int X = 0, w = 0;
  char ch = 0;
  while (!isdigit(ch)) {
    w |= ch == '-';
    ch = getchar();
  }
  while (isdigit(ch)) {
    X = (X << 3) + (X << 1) + (ch ^ 48);
    ch = getchar();
  }
  return w ? -X : X;
}
int main() {
  int n = read();
  for (int i = 1; i <= n; i++) {
    scanf("%s", a[i] + 1);
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (a[i][j] == 'X' && a[i][j] == a[i - 1][j - 1] &&
          a[i][j] == a[i - 1][j + 1] && a[i][j] == a[i + 1][j - 1] &&
          a[i][j] == a[i + 1][j + 1]) {
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
