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