#include <bits/stdc++.h>
using namespace std;
int n, ans = 0;
char m[501][501];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) cin >> m[i][j];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      if (m[i][j] == 'X') {
        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')
          ans++;
      }
    }
  cout << ans << endl;
  return 0;
}
