#include <bits/stdc++.h>
using namespace std;
int n;
char ch[510][510];
int tx[4] = {1, 1, -1, -1}, ty[4] = {-1, 1, 1, -1};
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%s", ch[i] + 1);
  int ans = 0;
  for (int i = 2; i < n; i++)
    for (int j = 2, k; j < n; j++) {
      if (ch[i][j] == 'X') {
        for (k = 0; k < 4; k++) {
          if (ch[i + tx[k]][j + ty[k]] != 'X') break;
        }
        if (k == 4) ans++;
      }
    }
  printf("%d\n", ans);
  return 0;
}
