#include <bits/stdc++.h>
using namespace std;
inline void boost() {
  ios_base::sync_with_stdio();
  cin.tie(0);
  cout.tie(0);
}
const long long maxn = 1e3 + 123;
const long long inf = 1e9 + 123;
const long long mod = 1e9 + 7;
const double pi = acos(-1);
char a[maxn][maxn];
int main() {
  boost();
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      cin >> a[i][j];
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (a[i + 1][j + 1] == 'X' && a[i - 1][j - 1] == 'X' &&
          a[i - 1][j + 1] == 'X' && a[i + 1][j - 1] == 'X' && a[i][j] == 'X') {
        ans++;
      }
    }
  }
  cout << ans;
  return 0;
}
