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