#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, cnt = 0;
  string str[505];
  string s;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> s;
    str[i] = "";
    str[i] += s;
  }
  for (long long i = 1; i <= n - 2; i++) {
    for (long long j = 1; j <= n - 2; j++) {
      if (str[i][j] == 'X' && str[i - 1][j - 1] == 'X' &&
          str[i + 1][j - 1] == 'X' && str[i + 1][j + 1] == 'X' &&
          str[i - 1][j + 1] == 'X')
        cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}
