#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <math.h>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
int n;
char temp[505][505];
int ans;
bool ok(int i, int j) {
bool flag = false;
int s1 = temp[i][j] - 'X';
int s2 = temp[i-1][j-1] - 'X';
int s3 = temp[i-1][j+1] - 'X';
int s4 = temp[i+1][j-1] - 'X';
int s5 = temp[i+1][j+1] - 'X';
if ((s1 + s2 + s3 + s4 + s5) == 0) {
flag = true;
}
return flag;
}
int main() {
scanf("%d", &n);
getchar();
for (int i = 1;i <= n;++i) {
for (int j = 1;j <= n;++j) {
scanf("%c", &temp[i][j]);
}
getchar();
}
for (int i = 1;i <= n;++i) {
for (int j = 1;j <= n;++j) {
if (ok(i, j) == true) {
ans++;
}
}
}
printf("%d\n", ans);
return 0;
}