#include <bits/stdc++.h>
using namespace std;
int x[] = {-1, -1, 1, 1};
int y[] = {-1, 1, -1, 1};
int main() {
  int n;
  while (cin >> n) {
    char a[n + 1][n + 1];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) cin >> a[i][j];
    }
    int cnt = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (a[i][j] == 'X') {
          int xx, yy;
          bool f = 0;
          for (int k = 0; k < 4; k++) {
            xx = i + x[k];
            yy = j + y[k];
            if (xx >= n || xx < 0 || yy >= n || yy < 0 || a[xx][yy] == '.') {
              f = 1;
              break;
            }
          }
          if (!f) cnt++;
        }
      }
    }
    cout << cnt << endl;
  }
}
