#include <bits/stdc++.h>
using namespace std;
int n;
char s[1005][1005];
int ans;
int x[] = {1, 1, -1, -1};
int y[] = {-1, 1, -1, 1};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> s[i];
  for (int i = 1; i < n - 1; i++)
    for (int j = 1; j < n - 1; j++) {
      if (s[i][j] == 'X') {
        int cnt = 0;
        for (int k = 0; k < 4; k++) {
          int i2 = i + y[k];
          int j2 = j + x[k];
          if (i2 >= 0 && i2 < n && j2 >= 0 && j2 < n && s[i2][j2] == 'X') cnt++;
        }
        if (cnt == 4) ans++;
      }
    }
  cout << ans;
  return 0;
}
