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