#include <bits/stdc++.h>
using namespace std;
int x[] = {-1, -1, 1, 1};
int y[] = {-1, 1, -1, 1};
int main() {
  int i, j, k, l, m = 0, n, cnt = 0;
  cin >> n;
  char a[n + 10][n + 10];
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++) cin >> a[i][j];
  for (i = 1; i < n - 1; i++)
    for (j = 1; j < n - 1; j++) {
      if (a[i][j] == 'X') {
        m = 0;
        for (k = 0; k < 4; k++) {
          if (a[i + x[k]][j + y[k]] == 'X') m++;
        }
        if (m == 4) cnt++;
      }
    }
  cout << cnt << endl;
}
