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