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