#include <bits/stdc++.h>
using namespace std;
char c[2333][2333];
int main() {
  int n, ans = 0;
  cin >> n;
  for (register int i = 1; i <= n; i++) scanf("%s", c[i] + 1);
  for (register int i = 1; i <= n; i++)
    for (register int j = 1; j <= n; j++)
      ans +=
          (c[i][j] == 'X' && c[i - 1][j - 1] == 'X' && c[i - 1][j + 1] == 'X' &&
           c[i + 1][j - 1] == 'X' && c[i + 1][j + 1] == 'X');
  cout << ans;
  return 0;
}
