#include <bits/stdc++.h>
using namespace std;
long long N = 500005;
long long MAX = 9223372036854775807;
long long MOD = 1000000007;
long long n;
long double PI = 4 * atan(1);
bool valid(int x, int y) { return (x >= 0 && x < n && y >= 0 && y < n); }
int main() {
  cin >> n;
  vector<string> A(n);
  for (int i = 0; i < n; i++) cin >> A[i];
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      long long x1 = i - 1, y1 = j - 1, x2 = i - 1, y2 = j + 1, x3 = i + 1,
                y3 = j - 1, x4 = i + 1, y4 = j + 1;
      if (valid(x1, y1) && valid(x2, y2) && valid(x3, y3) && valid(x4, y4)) {
        if (A[x1][y1] == 'X' && A[x2][y2] == 'X' && A[x3][y3] == 'X' &&
            A[x4][y4] == 'X' && A[i][j] == 'X')
          ans++;
      }
    }
  }
  cout << ans;
  return 0;
}
