#include <bits/stdc++.h>
using namespace std;
int n, dem = 0;
char m[505][505];
void input() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      cin >> m[i][j];
    }
  }
  return;
}
void solve() {
  for (int i = 2; i < n; i++) {
    for (int j = 2; j < n; j++) {
      if (m[i][j] == '.') {
        continue;
      } else if (m[i][j] == m[i + 1][j + 1] && m[i][j] == m[i - 1][j - 1] &&
                 m[i][j] == m[i - 1][j + 1] && m[i][j] == m[i + 1][j - 1]) {
        dem++;
      }
    }
  }
  return;
}
void output() {
  cout << dem;
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  input();
  solve();
  output();
  return 0;
}
