Lunar New Year is approaching, and you bought a matrix with lots of "crosses".

This matrix $M$ of size $n \times n$ contains only 'X' and '.' (without quotes). The element in the $i$-th row and the $j$-th column $(i, j)$ is defined as $M(i, j)$, where $1 \leq i, j \leq n$. We define a cross appearing in the $i$-th row and the $j$-th column ($1 < i, j < n$) if and only if $M(i, j) = M(i - 1, j - 1) = M(i - 1, j + 1) = M(i + 1, j - 1) = M(i + 1, j + 1) = $ 'X'.

The following figure illustrates a cross appearing at position $(2, 2)$ in a $3 \times 3$ matrix. 

X.X

.X.

X.X

 

Your task is to find out the number of crosses in the given matrix $M$. Two crosses are different if and only if they appear in different rows or columns.


-----Input-----

The first line contains only one positive integer $n$ ($1 \leq n \leq 500$), denoting the size of the matrix $M$.

The following $n$ lines illustrate the matrix $M$. Each line contains exactly $n$ characters, each of them is 'X' or '.'. The $j$-th element in the $i$-th line represents $M(i, j)$, where $1 \leq i, j \leq n$.


-----Output-----

Output a single line containing only one integer number $k$ — the number of crosses in the given matrix $M$.


-----Examples-----
Input
5
.....
.XXX.
.XXX.
.XXX.
.....

Output
1

Input
2
XX
XX

Output
0

Input
6
......
X.X.X.
.X.X.X
X.X.X.
.X.X.X
......

Output
4



-----Note-----

In the first sample, a cross appears at $(3, 3)$, so the answer is $1$.

In the second sample, no crosses appear since $n < 3$, so the answer is $0$.

In the third sample, crosses appear at $(3, 2)$, $(3, 4)$, $(4, 3)$, $(4, 5)$, so the answer is $4$.

Source: codeforces | Difficulty: EASY
Tags: Implementation


Solutions:
def fastio():
	import sys
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
(n,) = I()
l = ['0' * (n + 2)]
for i in range(n):
	l.append('0' + input() + '0')
l.append('0' * (n + 2))
ans = 0
for i in range(1, n + 1):
	for j in range(1, n + 1):
		if l[i][j] == l[i - 1][j - 1] == l[i - 1][j + 1] == l[i + 1][j - 1] == l[i + 1][j + 1] == 'X':
			ans += 1
print(ans)


def main():
	n = int(input())
	mat = []
	for _ in range(n):
		mat.append(list(input()))
	ret = 0
	for i in range(1, n - 1):
		for j in range(1, n - 1):
			if mat[i][j] == mat[i - 1][j - 1] == mat[i + 1][j - 1] == mat[i - 1][j + 1] == mat[i + 1][j + 1] == 'X':
				ret += 1
	print(ret)
main()


cases = int(input())
M = []
while cases:
	cases -= 1
	s = input()
	M.append(s)
ct = 0
for (i, row) in enumerate(M[1:-1], start=1):
	for (j, col) in enumerate(row[1:-1], start=1):
		if M[i][j] == M[i - 1][j - 1] == M[i - 1][j + 1] == M[i + 1][j - 1] == M[i + 1][j + 1] == 'X':
			ct += 1
print(ct)


n = int(input())
a = []
for i in range(n):
	s = input()
	b = []
	for j in s:
		b.append(j)
	a.append(b)
c = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if a[i][j] == 'X' and a[i + 1][j + 1] == 'X' and (a[i + 1][j - 1] == 'X') and (a[i - 1][j + 1] == 'X') and (a[i - 1][j - 1] == 'X'):
			c += 1
print(c)


n = int(input())
M = [input() for i in range(n)]
ANS = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if M[i][j] == M[i - 1][j - 1] == M[i - 1][j + 1] == M[i + 1][j - 1] == M[i + 1][j + 1] == 'X':
			ANS += 1
print(ANS)


n = int(input())
m = []
cnt = 0
for i in range(n):
	m.append(str(input()))
for i in range(n):
	for j in range(n):
		if i != 0 and j != 0 and (i < n - 1) and (j < n - 1) and (m[i][j] == 'X'):
			if m[i - 1][j - 1] == 'X' and m[i + 1][j - 1] == 'X' and (m[i - 1][j + 1] == 'X') and (m[i + 1][j + 1] == 'X'):
				cnt += 1
print(cnt)


n = int(input())
data = []
for i in range(n):
	data.append(input())
c = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if data[i][j] == data[i - 1][j - 1] == data[i + 1][j + 1] == data[i - 1][j + 1] == data[i + 1][j - 1] == 'X':
			c += 1
print(c)


from sys import stdin, stdout
nmbr = lambda : int(stdin.readline())
lst = lambda : list(map(int, stdin.readline().split()))

def valid(i, j):
	return 0 <= i < n and 0 <= j < n

def fn(x, y):
	for (xx, yy) in zip([-1, -1, 1, 1], [-1, 1, -1, 1]):
		if valid(x + xx, y + yy) and a[x + xx][y + yy] == 'X':
			continue
		else:
			return False
	return True
for _ in range(1):
	n = nmbr()
	ans = 0
	a = [input() for _ in range(n)]
	for i in range(n):
		for j in range(n):
			if a[i][j] == 'X' and fn(i, j):
				ans += 1
	print(ans)


n = int(input())
a = [input() for _ in range(n)]
result = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if a[i][j] == 'X' and a[i - 1][j - 1] == 'X' and (a[i - 1][j + 1] == 'X') and (a[i + 1][j - 1] == 'X') and (a[i + 1][j + 1] == 'X'):
			result += 1
print(result)


n = int(input())
m = [input() for s in range(n)]
count = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if m[i][j] == m[i - 1][j - 1] == m[i - 1][j + 1] == m[i + 1][j + 1] == m[i + 1][j - 1] == 'X':
			count += 1
print(count)

def __starting_point():
	pass
__starting_point()


from pprint import pprint
import sys
n = int(input())
maze = []
for _ in range(n):
	l = list(input())
	maze.append(l)
res = 0
for hh in range(n - 2):
	for ww in range(n - 2):
		if maze[hh][ww] == 'X' and maze[hh][ww + 2] == 'X':
			if maze[hh + 1][ww + 1] == 'X':
				if maze[hh + 2][ww] == 'X' and maze[hh + 2][ww + 2] == 'X':
					res += 1
print(res)


number = int(input())
mat = []
ans = 0
for i in range(number):
	mat.append(' '.join(input()).split())
for i in range(1, number - 1):
	for j in range(1, number - 1):
		if mat[i][j] == 'X':
			if mat[i - 1][j - 1] == 'X':
				if mat[i - 1][j + 1] == 'X':
					if mat[i + 1][j - 1] == 'X':
						if mat[i + 1][j + 1] == 'X':
							ans += 1
print(ans)


n = int(input())
arr = [None] * n
for i in range(n):
	arr[i] = input().strip()
cnt = 0
for i in range(1, n - 1):
	for j in range(1, len(arr[i]) - 1):
		if arr[i][j] == 'X' and arr[i - 1][j - 1] == 'X' and (arr[i - 1][j + 1] == 'X') and (arr[i + 1][j - 1] == 'X') and (arr[i + 1][j + 1] == 'X'):
			cnt += 1
print(cnt)


n = int(input())
l = []
for i in range(n):
	l.append(input())
count = 0
for i in range(n):
	for j in range(n):
		now = 0
		if l[i][j] == 'X':
			try:
				if i - 1 >= 0 and j - 1 >= 0 and (l[i - 1][j - 1] == l[i][j]):
					now += 1
			except:
				pass
			try:
				if j - 1 >= 0 and l[i + 1][j - 1] == l[i][j]:
					now += 1
			except:
				pass
			try:
				if i - 1 >= 0 and l[i - 1][j + 1] == l[i][j]:
					now += 1
			except:
				pass
			try:
				if l[i + 1][j + 1] == l[i][j]:
					now += 1
			except:
				pass
			if now == 4:
				count += 1
		now = 0
print(count)


import collections
import time
import os
import sys
import bisect
import heapq
N = int(input())
A = []
for i in range(N):
	A.append(list(input()))
M = len(A[0])
ans = 0
for r in range(N):
	for c in range(M):
		if A[r][c] == 'X' and all([0 <= nr < N and 0 <= nc < M and (A[nr][nc] == 'X') for (nr, nc) in [(r - 1, c - 1), (r - 1, c + 1), (r + 1, c - 1), (r + 1, c + 1)]]):
			ans += 1
print(ans)


n = int(input())
mat = []
count = 0
i = 0
while i < n:
	mat.append([])
	i += 1
for i in range(n):
	inputs = input()
	for ch in inputs:
		mat[i].append(ch)
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if mat[i][j] == 'X':
			if mat[i - 1][j - 1] == 'X' and mat[i - 1][j + 1] == 'X' and (mat[i + 1][j - 1] == 'X') and (mat[i + 1][j + 1] == 'X'):
				count += 1
print(count)


n = int(input())
m = [input() for _ in range(n)]
c = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if m[i][j] == m[i - 1][j - 1] == m[i - 1][j + 1] == m[i + 1][j - 1] == m[i + 1][j + 1] == 'X':
			c += 1
print(c)


from sys import stdin, stdout

def inp():
	return stdin.readline()

def minp():
	return map(int, stdin.readline().rstrip().split())

def linp():
	return list(minp())

def main():
	n = int(inp())
	lst = [[j for j in input().strip()] for i in range(n)]
	cnt = 0
	for i in range(1, n - 1):
		for j in range(1, n - 1):
			if lst[i][j] == 'X' and lst[i - 1][j - 1] == 'X' and (lst[i - 1][j + 1] == 'X') and (lst[i + 1][j - 1] == 'X') and (lst[i + 1][j + 1] == 'X'):
				cnt += 1
	print(cnt)
main()


def read_nums():
	return [int(x) for x in input().split()]

def is_cross(matrix, i, j):
	if matrix[i][j] != 'X':
		return False
	if i == 0 or j == 0 or i == len(matrix) - 1 or (j == len(matrix) - 1):
		return False
	for di in (-1, 1):
		for dj in (-1, 1):
			if matrix[i][j] != matrix[i + di][j + dj]:
				return False
	return True

def solve(matrix):
	res = 0
	for i in range(len(matrix)):
		for j in range(len(matrix)):
			if is_cross(matrix, i, j):
				res += 1
	return res

def main():
	(n,) = read_nums()
	matrix = []
	for _ in range(n):
		matrix.append(input())
	print(solve(matrix))
main()


n = int(input())
if n < 3:
	print(0)
	exit()
l1 = []
for i in range(n):
	l = list(input())
	l1.append(l)
c = 0
for i in range(n):
	for j in range(n):
		if i + 1 < n and j + 1 < n and (i - 1 > -1) and (j - 1 > -1):
			if l1[i][j] == 'X':
				if l1[i - 1][j - 1] == 'X':
					if l1[i - 1][j + 1] == 'X':
						if l1[i + 1][j - 1] == 'X':
							if l1[i + 1][j + 1] == 'X':
								c += 1
print(c)


n = int(input())
M = []
for i in range(n):
	s = input()
	buf = [j for j in s]
	M.append(buf)
if n < 3:
	print(0)
else:
	ans = 0
	for i in range(1, n - 1):
		for j in range(1, n - 1):
			if M[i][j] == M[i - 1][j - 1] == M[i - 1][j + 1] == M[i + 1][j - 1] == M[i + 1][j + 1] == 'X':
				ans += 1
	print(ans)


n = int(input())
A = []
for x in range(n):
	A.append(input())
ans = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if A[i][j] == 'X' and A[i + 1][j - 1] == 'X' and (A[i - 1][j + 1] == 'X') and (A[i + 1][j + 1] == 'X') and (A[i - 1][j - 1] == 'X'):
			ans += 1
print(ans)


k = int(input())
a = input()
for i in range(k - 1):
	a += input()
ch = 0
kol = 0
data = [[[] for i in range(k + 2)] for i in range(k + 2)]
for i in range(1, k + 1):
	for u in range(1, k + 1):
		data[i][u] = a[ch]
		ch += 1
for i in range(k):
	for u in range(k):
		if data[i][u] == 'X':
			if data[i - 1][u - 1] == data[i - 1][u + 1] == data[i + 1][u - 1] == data[i + 1][u + 1] == 'X':
				kol += 1
print(kol)


n = int(input())
(v, z) = ([], 0)
for _ in range(n):
	a = list(input())
	v.append(a)
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if v[i][j] == 'X':
			if v[i - 1][j - 1] == v[i + 1][j - 1] == v[i - 1][j + 1] == v[i + 1][j + 1] == 'X':
				z += 1
		else:
			pass
print(z)


n = int(input())
a = [list(input()) for i in range(n)]
counter = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if a[i][j] == a[i - 1][j - 1] == a[i - 1][j + 1] == a[i + 1][j - 1] == a[i + 1][j + 1] == 'X':
			counter += 1
print(counter)


n = int(input())
li = []
for i in range(1, n + 1):
	li.append(input())
ans = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if li[i][j] == 'X' and li[i - 1][j - 1] == 'X' and (li[i + 1][j + 1] == 'X') and (li[i - 1][j + 1] == 'X') and (li[i + 1][j - 1] == 'X'):
			ans += 1
print(ans)


x = int(input())
arr = []
for i in range(0, x):
	cur = input()
	arr.append(cur)
sum = 0
for i in range(1, x - 1):
	for j in range(1, x - 1):
		if arr[i][j] == 'X' and arr[i - 1][j - 1] == 'X' and (arr[i - 1][j + 1] == 'X') and (arr[i + 1][j - 1] == 'X') and (arr[i + 1][j + 1] == 'X'):
			sum += 1
print(sum)


t = int(input())
a = []
count = 0
for i in range(t):
	s = input()
	a.append(s)
for i in range(1, t - 1):
	for j in range(1, t - 1):
		if a[i][j] == 'X' and a[i][j] == a[i - 1][j - 1] and (a[i - 1][j - 1] == a[i - 1][j + 1]) and (a[i - 1][j + 1] == a[i + 1][j - 1]) and (a[i + 1][j - 1] == a[i + 1][j + 1]):
			count += 1
print(count)


n = int(input())
a = []
ans = 0
for i in range(n):
	a1 = input()
	a1 = list(a1)
	a.append(a1)
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if a[i][j] == a[i - 1][j - 1] == a[i - 1][j + 1] == a[i + 1][j - 1] == a[i + 1][j + 1] == 'X':
			ans += 1
print(ans)


n = int(input())
ans = []
for i in range(n):
	ans.append(list(input()))
count = 0
for i in range(n):
	for j in range(n):
		if ans[i][j] == 'X':
			if i - 1 > -1 and j - 1 > -1 and (i + 1 < n) and (j + 1 < n) and (ans[i - 1][j - 1] == 'X') and (ans[i + 1][j + 1] == 'X') and (ans[i + 1][j - 1] == 'X') and (ans[i - 1][j + 1] == 'X'):
				count += 1
print(count)


n = int(input())
inlist = []
for i in range(n):
	inlist.append(list(input()))
count = 0
if n >= 3:
	for i in range(1, n - 1):
		for j in range(1, n - 1):
			if inlist[i][j] == 'X' and inlist[i - 1][j - 1] == 'X' and (inlist[i - 1][j + 1] == 'X') and (inlist[i + 1][j - 1] == 'X') and (inlist[i + 1][j + 1] == 'X'):
				count += 1
else:
	count = 0
print(count)


n = int(input())
a = []
i = 0
while i < n:
	b = input()
	a.append(b)
	i += 1
i = 1
ans = 0
while i < n - 1:
	j = 1
	while j < n - 1:
		if a[i][j] == 'X' and a[i - 1][j - 1] == 'X' and (a[i - 1][j + 1] == 'X') and (a[i + 1][j + 1] == 'X') and (a[i + 1][j - 1] == 'X'):
			ans += 1
		j += 1
	i += 1
print(ans)


n = int(input())
mat = []
for _ in range(n):
	mat.append(list(input()))
cnt = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		try:
			if mat[i][j] == mat[i - 1][j - 1] == mat[i - 1][j + 1] == mat[i + 1][j - 1] == mat[i + 1][j + 1] == 'X':
				cnt += 1
		except:
			pass
print(cnt)


n = int(input())
mas = ['.' * (n + 2)]
for i in range(n):
	mas.append('.' + input() + '.')
mas.append('.' * (n + 2))
ans = 0
for i in range(1, n + 1):
	for j in range(1, n + 1):
		if mas[i - 1][j - 1] + mas[i - 1][j + 1] + mas[i + 1][j - 1] + mas[i + 1][j + 1] + mas[i][j] == 'XXXXX':
			ans += 1
print(ans)


n = int(input())
a = [input() for k in [0] * n]
(y, x) = ([0, 0, 1, 2, 2], [0, 2, 1, 0, 2])
print(sum((1 for i in range(n - 2) for j in range(n - 2) if all((a[i + y[k]][j + x[k]] == 'X' for k in range(5))))))


a = int(input())
lst = []
for i in range(a):
	lst.append(list(input()))
answer = 0
for i in range(1, a - 1):
	for j in range(1, a - 1):
		if lst[i][j] == lst[i - 1][j - 1] == lst[i - 1][j + 1] == lst[i + 1][j - 1] == lst[i + 1][j + 1] == 'X':
			answer += 1
print(answer)


n = int(input())
m = []
ans = 0
for i in range(n):
	m.append(list(input()))
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if m[i][j] == m[i - 1][j - 1] == m[i - 1][j + 1] == m[i + 1][j - 1] == m[i + 1][j + 1] == 'X':
			ans += 1
print(ans)


n = int(input())
b = [[''] * n for i in range(n)]
cnt = 0
for i in range(n):
	c = input()
	for j in range(n):
		b[i][j] = c[j]
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if b[i][j] == 'X' and b[i][j] == b[i - 1][j - 1] and (b[i][j] == b[i + 1][j + 1]) and (b[i][j] == b[i - 1][j + 1]) and (b[i][j] == b[i + 1][j - 1]):
			cnt += 1
print(cnt)


def isCross(px, py, arr):
	if arr[px][py] != 'X':
		return 0
	if arr[px - 1][py - 1] != 'X':
		return 0
	if arr[px + 1][py + 1] != 'X':
		return 0
	if arr[px - 1][py + 1] != 'X':
		return 0
	if arr[px + 1][py - 1] != 'X':
		return 0
	return 1
n = int(input())
if n < 3:
	print(0)
	exit(0)
m = []
count = 0
for i in range(n):
	m.append(input())
for i in range(1, n - 1):
	for j in range(1, n - 1):
		count += isCross(i, j, m)
print(count)


def issafe(i, j, n, a):
	return i >= 0 and j >= 0 and (i < n) and (j < n) and (a[i][j] == 'X')
n = int(input())
m = n
a = [[] for i in range(n)]
for i in range(n):
	a[i] = input()
l = []
count1 = 0
for i in range(n):
	for j in range(n):
		if (issafe(i - 1, j - 1, n, a) and issafe(i - 1, j + 1, n, a) and issafe(i + 1, j - 1, n, a) and issafe(i + 1, j + 1, n, a)) and issafe(i, j, n, a):
			count1 += 1
print(count1)


n = int(input())
a = [''] * n
for i in range(n):
	a[i] = input()
sol = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if a[i][j] == 'X' and a[i][j] == a[i - 1][j - 1] == a[i - 1][j + 1] == a[i + 1][j - 1] == a[i + 1][j + 1]:
			sol += 1
print(sol)


n = int(input())
mat = ['0' for i in range(n)]
for i in range(n):
	mat[i] = input()
c = 0
for i in range(1, n - 1, 1):
	for j in range(1, n - 1, 1):
		if mat[i][j] == 'X':
			if mat[i - 1][j - 1] == 'X' and mat[i - 1][j + 1] == 'X' and (mat[i + 1][j - 1] == 'X') and (mat[i + 1][j + 1] == 'X'):
				c += 1
print(c)


n = int(input())
l = []
for i in range(n):
	s = input()
	l.append(list(s))
count = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if l[i][j] == l[i - 1][j - 1] == l[i - 1][j + 1] == l[i + 1][j - 1] == l[i + 1][j + 1] == 'X':
			count += 1
print(count)


n = int(input())
mat = [['.' for i in range(n)] for j in range(n)]
for i in range(n):
	line = input()
	for j in range(n):
		mat[i][j] = line[j]
count = 0
for i in range(n):
	for j in range(n):
		if i - 1 >= 0 and i + 1 < n and (j - 1 >= 0) and (j + 1 < n):
			if mat[i][j] == mat[i - 1][j - 1] == mat[i + 1][j + 1] == mat[i - 1][j + 1] == mat[i + 1][j - 1] == 'X':
				count += 1
print(count)


n = int(input())
if n < 3:
	print(0)
else:
	matrix = list()
	for i in range(n):
		matrix.append(input())
	ans = 0
	for i in range(1, n - 1):
		for j in range(1, n - 1):
			if matrix[i][j] == 'X' and matrix[i - 1][j - 1] == 'X' and (matrix[i - 1][j + 1] == 'X') and (matrix[i + 1][j - 1] == 'X') and (matrix[i + 1][j + 1] == 'X'):
				ans += 1
	print(ans)


import math, sys, bisect, heapq
from collections import defaultdict, Counter, deque
from itertools import groupby, accumulate
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
ilele = lambda : map(int, input().split())
alele = lambda : list(map(int, input().split()))

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def Y(c):
	print(['NO', 'YES'][c])

def y(c):
	print(['no', 'yes'][c])

def Yy(c):
	print(['No', 'Yes'][c])
N = int(input())
A = []
for i in range(N):
	S = input()
	A.append(S)
if N < 3:
	print(0)
else:
	count = 0
	for i in range(1, N - 1):
		for j in range(1, N - 1):
			if A[i][j] == A[i - 1][j - 1] == A[i - 1][j + 1] == A[i + 1][j - 1] == A[i + 1][j + 1] == 'X':
				count += 1
	print(count)


n = int(input())
a = [0] * 500
k = 0
for i in range(n):
	a[i] = str(input())
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if a[i][j] == 'X':
			if a[i - 1][j - 1] == 'X' and a[i + 1][j + 1] == 'X' and (a[i + 1][j - 1] == 'X') and (a[i - 1][j + 1] == 'X'):
				k += 1
print(k)


from sys import stdin
arr = []
n = int(stdin.readline())
for _ in range(n):
	s = stdin.readline().strip()
	arr.append(s)
count = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if arr[i][j] == 'X' and arr[i - 1][j - 1] == 'X' and (arr[i - 1][j + 1] == 'X') and (arr[i + 1][j - 1] == 'X') and (arr[i + 1][j + 1] == 'X'):
			count += 1
		else:
			pass
print(count)


n = int(input())
c = 0
Matrix = []
for i in range(n):
	Matrix.append(list(input()))
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if Matrix[i][j] == Matrix[i - 1][j - 1] and Matrix[i][j] == Matrix[i - 1][j + 1] and (Matrix[i][j] == Matrix[i + 1][j - 1]) and (Matrix[i][j] == Matrix[i + 1][j + 1]) and (Matrix[i][j] == 'X'):
			c += 1
print(c)


n = int(input())
g = [input() for i in range(n)]
print(sum((g[i][j] == 'X' and g[i - 1][j - 1] == 'X' and (g[i - 1][j + 1] == 'X') and (g[i + 1][j - 1] == 'X') and (g[i + 1][j + 1] == 'X') for i in range(1, n - 1) for j in range(1, n - 1))))


n = int(input())
k = []
for i in range(n):
	s = input()
	k.append(s)
p = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if k[i][j] == 'X' and k[i - 1][j - 1] == 'X' and (k[i - 1][j + 1] == 'X') and (k[i + 1][j - 1] == 'X') and (k[i + 1][j + 1] == 'X'):
			p += 1
print(p)


def is_cross(i, j, table):
	return table[i][j] == 'X' and table[i - 1][j - 1] == 'X' and (table[i - 1][j + 1] == 'X') and (table[i + 1][j - 1] == 'X') and (table[i + 1][j + 1] == 'X')
n = int(input())
table = []
for i in range(n):
	table.append(list(input()))
cnt = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if is_cross(i, j, table):
			cnt += 1
print(cnt)


n = int(input())
a = []
for i in range(n):
	c = list(input())
	a.append(c)
flag = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if a[i][j] == a[i - 1][j - 1] == a[i - 1][j + 1] == a[i + 1][j - 1] == a[i + 1][j + 1] == 'X':
			flag += 1
print(flag)


n = int(input())
s = []
for i in range(n):
	ip = input()
	s.append(ip)
count = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if s[i][j] == 'X' and s[i - 1][j - 1] == 'X' and (s[i - 1][j + 1] == 'X') and (s[i + 1][j - 1] == 'X') and (s[i + 1][j + 1] == 'X'):
			count += 1
print(count)


n = int(input())
a = [[0] * n for i in range(n)]
for i in range(n):
	b = input().rstrip()
	for j in range(n):
		a[i][j] = b[j]
count = 0
for i in range(n):
	for j in range(n):
		if i - 1 >= 0 and i + 1 < n and (j + 1 < n) and (j - 1 >= 0):
			if a[i][j] == 'X' and a[i - 1][j - 1] == 'X' and (a[i + 1][j + 1] == 'X') and (a[i + 1][j - 1] == 'X') and (a[i - 1][j + 1] == 'X') and (a[i + 1][j - 1] == 'X'):
				count += 1
print(count)


def main():
	n = int(input())
	M = []
	out = []
	count = 0
	for _ in range(n):
		M.append(list(input()))
	for i in range(1, n - 1):
		for j in range(1, n - 1):
			if M[i][j] == M[i - 1][j - 1] == M[i - 1][j + 1] == M[i + 1][j - 1] == M[i + 1][j + 1] == 'X':
				out.append((i + 1, j + 1))
				count += 1
	print(count)
main()


n = int(input())
a = [list(input()) for i in range(n)]
cnt = 0
for i in range(n - 2):
	for j in range(n - 2):
		if a[i][j] == 'X' and a[i + 2][j] == 'X' and (a[i][j + 2] == 'X') and (a[i + 1][j + 1] == 'X') and (a[i + 2][j + 2] == 'X'):
			cnt += 1
print(cnt)


import sys
import heapq
import copy
from collections import deque
from collections import OrderedDict
from collections import Counter

def main():
	n = input()
	val = int(n)
	resp = 0
	data = []
	for i in range(0, val):
		txt = input()
		l1 = list(txt)
		data.append(l1)
	x1 = [-1, -1, 1, 1]
	y1 = [-1, 1, -1, 1]
	for i in range(0, val):
		for j in range(0, val):
			if data[i][j] == '.':
				continue
			veces = 0
			for k in range(0, 4):
				tmpx = i + x1[k]
				tmpy = j + y1[k]
				if tmpx >= 0 and tmpx < val and (tmpy >= 0) and (tmpy < val):
					if data[tmpx][tmpy] == 'X':
						veces += 1
			if veces == 4:
				resp += 1
	print(resp)
main()


(n, cnt) = (int(input()), 0)
cross = [input() for i in range(n)]
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if cross[i][j] == cross[i + 1][j + 1] == cross[i - 1][j + 1] == cross[i + 1][j - 1] == cross[i - 1][j - 1] == 'X':
			cnt += 1
print(cnt)


n = int(input())
s = []
for _ in range(n):
	s.append(input())
c = 0
X = 'X'
for x in range(1, n - 1):
	for y in range(1, n - 1):
		if s[x][y] == X and s[x - 1][y - 1] == X and (s[x + 1][y - 1] == X) and (s[x - 1][y + 1] == X) and (s[x + 1][y + 1] == X):
			c += 1
print(c)


n = int(input())
A = []
res = 0
for i in range(n):
	s = list(input())
	A.append(s)
for i in range(n):
	for j in range(n):
		if i == 0 or j == 0 or i == n - 1 or (j == n - 1):
			continue
		elif A[i][j] == 'X' and A[i - 1][j - 1] == 'X' and (A[i - 1][j + 1] == 'X') and (A[i + 1][j - 1] == 'X') and (A[i + 1][j + 1] == 'X'):
			res += 1
print(res)


import collections, atexit, math, sys, bisect
sys.setrecursionlimit(1000000)

def getIntList():
	return list(map(int, input().split()))
isdebug = False
try:
	import numpy

	def dprint(*args, **kwargs):
		print(*args, file=sys.stderr)
	dprint('debug mode')
	isdebug = True
except Exception:

	def dprint(*args, **kwargs):
		pass
inId = 1
outId = 0
if not isdebug:
	inId = 0
	outId = 0
if inId > 0:
	dprint('use input', inId)
	try:
		f = open('input' + str(inId) + '.txt', 'r')
		sys.stdin = f
	except Exception:
		dprint('invalid input file')
if outId > 0:
	dprint('use output', outId)
	try:
		f = open('stdout' + str(outId) + '.txt', 'w')
		sys.stdout = f
	except Exception:
		dprint('invalid output file')
	atexit.register(lambda : sys.stdout.close())
(N,) = getIntList()
zs = []
for i in range(N):
	zs.append(input())
dprint(zs)
r = 0
for a in range(1, N - 1):
	for b in range(1, N - 1):
		if zs[a][b] != 'X':
			continue
		if zs[a - 1][b - 1] == 'X' and zs[a - 1][b + 1] == 'X' and (zs[a + 1][b - 1] == 'X') and (zs[a + 1][b + 1] == 'X'):
			r += 1
print(r)


n = int(input())
row = []
for t in range(n):
	row.append([i for i in input()])
cnt = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if row[i][j] == 'X':
			if row[i - 1][j - 1] == row[i - 1][j + 1] == row[i + 1][j - 1] == row[i + 1][j + 1] == 'X':
				cnt += 1
print(cnt)


gi = lambda : list(map(int, input().strip().split()))
(n,) = gi()
m = [input() for e in range(n)]
ans = 0
if n < 3:
	print(0)
	exit()
for k in range(1, n - 1):
	for j in range(1, n - 1):
		if m[k][j] == m[k - 1][j - 1] == m[k - 1][j + 1] == m[k + 1][j - 1] == m[k + 1][j + 1] == 'X':
			ans += 1
print(ans)


n = int(input())
f = []
k = 0
for i in range(n):
	f.append(list(str(input())))
if n < 3:
	print(0)
else:
	for i in range(1, n - 1):
		for j in range(1, n - 1):
			if f[i][j] + f[i - 1][j + 1] + f[i + 1][j - 1] + f[i + 1][j + 1] + f[i - 1][j - 1] == 'XXXXX':
				k += 1
	print(k)


n = int(input())
table = []
crossNum = 0
for i in range(n):
	table.append(list(input()))
for row in range(1, n - 1):
	for column in range(1, n - 1):
		if table[row][column] == 'X':
			if table[row - 1][column - 1] == 'X' and table[row - 1][column + 1] == 'X' and (table[row + 1][column - 1] == 'X') and (table[row + 1][column + 1] == 'X'):
				crossNum += 1
print(crossNum)


n = int(input())
list = [list(input()) for y in range(n)]
cnt = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if list[i][j] == 'X' and list[i + 1][j + 1] == 'X' and (list[i - 1][j - 1] == 'X') and (list[i + 1][j - 1] == 'X') and (list[i - 1][j + 1] == 'X'):
			cnt += 1
print(cnt)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, queue, copy
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def I():
	return int(sys.stdin.readline())

def LS():
	return sys.stdin.readline().split()

def S():
	return input()

def main():
	n = I()
	l = [S() for _ in range(n)]
	aa = [(-1, -1), (1, -1), (-1, 1), (1, 1)]
	ans = 0
	for i in range(n):
		for j in range(n):
			f = 0
			for (y, x) in aa:
				if l[i][j] != 'X':
					continue
				if y + i < 0 or x + j < 0 or y + i >= n or (x + j >= n):
					continue
				if l[y + i][j + x] == 'X':
					f += 1
			if f == 4:
				ans += 1
	return ans
print(main())


def crosses(arr):
	m = len(arr)
	direc = [[1, -1], [1, 1], [-1, -1], [-1, 1]]
	big_count = 0
	for i in range(0, m):
		for j in range(0, m):
			if arr[i][j] != 'X':
				continue
			count = 0
			for d in direc:
				pos = (i + d[0], j + d[1])
				if 0 <= pos[0] < m and 0 <= pos[1] < m and (arr[pos[0]][pos[1]] == 'X'):
					count += 1
				else:
					break
			if count == 4:
				big_count += 1
	return big_count
m = int(input())
arr = [[None for i in range(m)] for i in range(m)]
for i in range(m):
	line = input()
	for j in range(m):
		arr[i][j] = line[j]
print(crosses(arr))


n = int(input())
a = [input() for i in range(n)]
c = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		c += a[i][j] == a[i - 1][j - 1] == a[i - 1][j + 1] == a[i + 1][j - 1] == a[i + 1][j + 1] == 'X'
print(c)


def answer():
	n = int(input())
	c = []
	i = 0
	while i < n:
		c.append(list(input()))
		i += 1
	i = 1
	ans = 0
	while i < len(c) - 1:
		j = 1
		while j < len(c) - 1:
			if c[i][j] == 'X':
				if c[i - 1][j + 1] == 'X' and c[i + 1][j + 1] == 'X' and (c[i - 1][j - 1] == 'X') and (c[i + 1][j - 1] == 'X'):
					ans += 1
			j += 1
		i += 1
	print(ans)
answer()


n = int(input())
l = [list(input()) for i in range(n)]
count = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if l[i][j] == 'X' and l[i][j] == l[i - 1][j - 1] and (l[i][j] == l[i - 1][j + 1]) and (l[i][j] == l[i + 1][j - 1]) and (l[i][j] == l[i + 1][j + 1]):
			count += 1
print(count)


n = int(input())
List = []
counter = 0
for i in range(0, n):
	List.append(input())
(i, j) = (1, 0)
while i < n - 1:
	for k in range(1, n - 1):
		if List[i][k] == 'X':
			j = k
			if List[i - 1][j - 1] == 'X' and List[i - 1][j + 1] == 'X':
				if List[i + 1][j - 1] == 'X' and List[i + 1][j + 1] == 'X':
					counter += 1
	i += 1
print(counter)


n = int(input())
matrix_size = n
MATRIX = []
while n:
	MATRIX.append(input())
	n -= 1
count = 0
for (i, line) in enumerate(MATRIX):
	for (j, value) in enumerate(line):
		if i - 1 >= 0 and i + 1 < matrix_size and (j - 1 >= 0) and (j + 1 < matrix_size):
			count += int(value == 'X' and MATRIX[i - 1][j - 1] == value and (MATRIX[i - 1][j + 1] == value) and (MATRIX[i + 1][j - 1] == value) and (MATRIX[i + 1][j + 1] == value))
print(count)


n = int(input())
m = []
for _ in range(n):
	row = list(input())
	m.append(row)
count = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if m[i][j] == 'X' and m[i][j] == m[i - 1][j - 1] and (m[i][j] == m[i + 1][j + 1]) and (m[i][j] == m[i - 1][j + 1]) and (m[i][j] == m[i + 1][j - 1]):
			count += 1
print(count)


n = int(input())
a = []
for k in range(n):
	b = list(input())
	a.append(b)
if n < 3:
	print(0)
else:
	ct = 0
	for k in range(1, n - 1):
		for p in range(1, n - 1):
			if a[k][p] == 'X' and a[k - 1][p - 1] == 'X' and (a[k - 1][p + 1] == 'X') and (a[k + 1][p + 1] == 'X') and (a[k + 1][p - 1] == 'X'):
				ct += 1
	print(ct)


n = int(input())
M = []
for i in range(n):
	M.append(input())
count = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if M[i][j] == 'X' and M[i - 1][j - 1] == 'X' and (M[i - 1][j + 1] == 'X') and (M[i + 1][j - 1] == 'X') and (M[i + 1][j + 1] == 'X'):
			count += 1
print(count)


matrix = []

def check(x, y):
	count = 0
	if matrix[x - 1][j - 1] == 'X':
		count += 1
	if matrix[x + 1][j + 1] == 'X':
		count += 1
	if matrix[x + 1][j - 1] == 'X':
		count += 1
	if matrix[x - 1][j + 1] == 'X':
		count += 1
	if count != 4:
		return 0
	else:
		return 1
n = int(input())
if n < 3:
	print(0)
else:
	for i in range(n):
		matrix.append(list(input()))
	ans = 0
	for i in range(1, n - 1):
		for j in range(1, n - 1):
			if matrix[i][j] == 'X':
				ans += check(i, j)
	print(ans)


n = int(input())
a = [input().strip() for i in range(n)]
print(sum((a[i][j] == a[i - 1][j - 1] == a[i - 1][j + 1] == a[i + 1][j - 1] == a[i + 1][j + 1] == 'X' for i in range(1, n - 1) for j in range(1, n - 1))))


n = int(input())
m = []
for i in range(n):
	m.append(input())
cross = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		cross += int(m[i][j] == 'X' and m[i - 1][j - 1] == 'X' and (m[i - 1][j + 1] == 'X') and (m[i + 1][j - 1] == 'X') and (m[i + 1][j + 1] == 'X'))
print(cross)


n = int(input())
tot = []
for item in range(n):
	a = list(input())
	tot.append(a)
	counter = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if tot[i][j] == tot[i - 1][j - 1] == tot[i - 1][j + 1] == tot[i + 1][j - 1] == tot[i + 1][j + 1] == 'X':
			counter += 1
print(counter)


n = int(input())
M = []
for i in range(n):
	M.append(list(input()))
if n < 3:
	print(0)
	exit()
k = 0
pref = []
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if M[i][j] == 'X':
			if M[i - 1][j - 1] == 'X' and M[i - 1][j + 1] == 'X' and (M[i + 1][j - 1] == 'X') and (M[i + 1][j + 1] == 'X'):
				k += 1
print(k)


n = int(input())
ar = []
for i in range(n):
	ar += [input()]
ans = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if ar[i][j] == ar[i - 1][j - 1] and (ar[i][j] == ar[i - 1][j + 1] and (ar[i][j] == ar[i + 1][j - 1] and ar[i][j] == ar[i + 1][j + 1])) and (ar[i][j] == 'X'):
			ans += 1
print(ans)


n = int(input())
matrix = []

def check(i, j):
	if matrix[i - 1][j - 1] != 'X':
		return 0
	if matrix[i + 1][j - 1] != 'X':
		return 0
	if matrix[i - 1][j + 1] != 'X':
		return 0
	if matrix[i + 1][j + 1] != 'X':
		return 0
	return 1
for i in range(n):
	matrix.append(list(input()))
ans = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if matrix[i][j] == 'X':
			if check(i, j) == 1:
				ans += 1
print(ans)


def rlist():
	return list(map(int, input().split()))

def rdi():
	return int(input())
n = rdi()
line = list()
for i in range(n):
	line.append(input())
cnt = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if line[i][j] == line[i - 1][j - 1] == line[i - 1][j + 1] == line[i + 1][j - 1] == line[i + 1][j + 1] == 'X':
			cnt += 1
print(cnt)


from collections import deque
import heapq
import math
import bisect
dx = [-1, 1, -1, 1]
dy = [1, 1, -1, -1]

def main():
	N = int(input())
	grid = []
	for i in range(N):
		grid.append(input())
	ans = 0
	for i in range(1, N - 1):
		for j in range(1, N - 1):
			if grid[i][j] == '.':
				continue
			ok = True
			for (di, dj) in zip(dx, dy):
				if grid[i + di][j + dj] == '.':
					ok = False
			if ok:
				ans += 1
	print(ans)
main()


n = int(input())
l = []
for _ in range(n):
	l.append(list(input()))
co = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if l[i][j] == 'X':
			if l[i - 1][j - 1] == 'X' and l[i + 1][j + 1] == 'X' and (l[i - 1][j + 1] == 'X') and (l[i + 1][j - 1] == 'X'):
				co += 1
print(co)


n = int(input())
arr = []
for i in range(n):
	s = str(input())
	arr.append(s)
ans = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if arr[i][j] == arr[i - 1][j - 1] == arr[i + 1][j + 1] == arr[i - 1][j + 1] == arr[i + 1][j - 1] == 'X':
			ans += 1
print(ans)


def chain(iterables):
	for it in iterables:
		for element in it:
			yield element
n = int(input())
m = [[] for _ in range(n)]
for i in range(n):
	m[i] = list(chain(input()))
count = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if m[i][j] == m[i - 1][j - 1] == m[i - 1][j + 1] == m[i + 1][j - 1] == m[i + 1][j + 1] == 'X':
			count += 1
print(count)


n = int(input())
L = []
for _ in range(n):
	t = input()
	L.append(t)
if n <= 2:
	print(0)
else:
	c = 0
	for i in range(1, n - 1):
		for j in range(1, n - 1):
			if L[i][j] == 'X' and L[i - 1][j - 1] == 'X' and (L[i + 1][j + 1] == 'X'):
				if L[i + 1][j - 1] == 'X' and L[i - 1][j + 1] == 'X':
					c += 1
	print(c)


size = int(input())
m = []
for _ in range(size):
	m.append([x for x in input()])
count = 0
for x in range(1, size - 1):
	for y in range(1, size - 1):
		if m[x][y] == 'X' and m[x - 1][y - 1] == 'X' and (m[x + 1][y - 1] == 'X') and (m[x - 1][y + 1] == 'X') and (m[x + 1][y + 1] == 'X'):
			count += 1
print(count)


import sys
import math
import bisect

def solve(A):
	n = len(A)
	ans = 0
	for i in range(n):
		for j in range(n):
			if i - 1 >= 0 and j - 1 >= 0 and (i + 1 < n) and (j + 1 < n) and (A[i - 1][j - 1] == 'X') and (A[i - 1][j + 1] == 'X') and (A[i][j] == 'X') and (A[i + 1][j - 1] == 'X') and (A[i + 1][j + 1] == 'X'):
				ans += 1
	return ans

def main():
	n = int(input())
	A = []
	for i in range(n):
		A.append(input())
	ans = solve(A)
	print(ans)
main()


n = int(input())
M = []
ans = 0
for i in range(n):
	s = input()
	M.append(s)
d = [[-1, -1], [-1, 1], [1, -1], [1, 1], [0, 0]]
for i in range(1, n - 1):
	for j in range(1, n - 1):
		is_cross = True
		for dir in d:
			if not M[i + dir[0]][j + dir[1]] == 'X':
				is_cross = False
				break
		if is_cross:
			ans += 1
print(ans)


n = int(input())
s = [[] for i in range(n)]
for i in range(n):
	a = input()
	for j in range(n):
		s[i].append(a[j])
k = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if s[i][j] == s[i - 1][j - 1] == s[i + 1][j - 1] == s[i - 1][j + 1] == s[i + 1][j + 1] == 'X':
			k += 1
print(k)


n = int(input())
b = []
for i in range(n):
	b.append(list(input()))
if n <= 2:
	print(0)
	exit()
ans = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if b[i][j] == b[i - 1][j - 1] == b[i - 1][j + 1] == b[i + 1][j - 1] == b[i + 1][j + 1] == 'X':
			ans += 1
print(ans)


n = int(input())
arr = []
for i in range(n):
	arr2 = input()
	arr.append(arr2)
c = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if arr[i][j] == arr[i - 1][j - 1] == arr[i + 1][j - 1] == arr[i - 1][j + 1] == arr[i + 1][j + 1] == 'X':
			c += 1
print(c)


n = int(input())
matrix = []
for i in range(n):
	matrix.append(input())
crosses = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if matrix[i][j] == matrix[i - 1][j - 1] == matrix[i + 1][j - 1] == matrix[i - 1][j + 1] == matrix[i + 1][j + 1] == 'X':
			crosses += 1
print(crosses)


import re, math, decimal, bisect

def read():
	return input().strip()

def iread():
	return int(input().strip())

def viread():
	return [int(_) for _ in input().strip().split()]
n = iread()
grid = []
for i in range(n):
	grid.append(read())
ans = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if grid[i][j] == 'X' and grid[i - 1][j - 1] == 'X' and (grid[i - 1][j + 1] == 'X') and (grid[i + 1][j - 1] == 'X') and (grid[i + 1][j + 1] == 'X'):
			ans += 1
print(ans)


n = int(input())
T = [[] for i in range(n)]
for i in range(n):
	a = list(input())
	T[i] = a
num = 0
for i in range(n):
	for j in range(n):
		if T[i][j] == 'X':
			for (dx, dy) in [(1, 1), (-1, 1), (1, -1), (-1, -1)]:
				(nx, ny) = (i + dx, j + dy)
				flag = True
				if 0 <= nx < n and 0 <= ny < n and (T[nx][ny] == 'X'):
					continue
				else:
					flag = False
					break
			if flag:
				num += 1
print(num)


m = []
if True:
	n = int(input())
	for _ in range(n):
		m.append(list(input()))
else:
	n = 500
	for _ in range(n):
		m.append(list('X' * n))
num_kr = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if m[i][j] == 'X' and m[i - 1][j - 1] == 'X' and (m[i + 1][j - 1] == 'X') and (m[i - 1][j + 1] == 'X') and (m[i + 1][j + 1] == 'X'):
			num_kr += 1
print(num_kr)


list_int_input = lambda inp: list(map(int, inp.split()))
int_input = lambda inp: int(inp)
string_to_list_input = lambda inp: list(inp)
n = int(input())
a = []
for i in range(n):
	a.append(string_to_list_input(input()))
summ = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if a[i][j] == 'X' and a[i][j] == a[i - 1][j - 1] and (a[i][j] == a[i + 1][j + 1]) and (a[i][j] == a[i - 1][j + 1]) and (a[i + 1][j - 1] == a[i][j]):
			summ += 1
print(summ)


import sys
n = int(input())
if n < 3:
	print(0)
	sys.exit(0)
m = list()
for i in range(n):
	k = input()
	m.append(list())
	for (l, j) in enumerate(k):
		m[i].append(j)
cnt = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if m[i][j] is 'X':
			if m[i - 1][j - 1] == m[i - 1][j + 1] == m[i + 1][j - 1] == m[i + 1][j + 1] == 'X':
				cnt += 1
print(cnt)


from sys import stdin, stdout
import math
from operator import *
from collections import Counter, defaultdict
import heapq
from itertools import permutations

def main():
	n = int(stdin.readline())
	A = []
	for i in range(n):
		A.append(input())
	count = 0
	if n <= 2:
		print(0)
	else:
		for i in range(1, n - 1):
			for j in range(1, n - 1):
				if A[i][j] == 'X' and A[i - 1][j - 1] == 'X' and (A[i - 1][j + 1] == 'X') and (A[i + 1][j - 1] == 'X') and (A[i + 1][j + 1] == 'X'):
					count = count + 1
		print(count)
main()


a = []
j = 0
x = int(input())
for i in range(x):
	a.append(input())
for i in range(1, x - 1):
	for p in range(1, x - 1):
		if a[i][p] == 'X' and a[i - 1][p - 1] == 'X' and (a[i - 1][p + 1] == 'X') and (a[i + 1][p - 1] == 'X') and (a[i + 1][p + 1] == 'X'):
			j += 1
print(j)


n = int(input())
m = []
for i in range(n):
	m.append([i for i in input()])
count = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if m[i][j] == 'X':
			if m[i][j] == m[i - 1][j - 1]:
				if m[i][j] == m[i - 1][j + 1]:
					if m[i][j] == m[i + 1][j + 1]:
						if m[i][j] == m[i + 1][j - 1]:
							count = count + 1
print(count)


n = int(input())
ar = []
for i in range(n):
	ar.append([])
	t = input()
	for j in range(n):
		ar[i].append(t[j])
if n < 5:
	print(0)
else:
	c = 0
	for i in range(1, n - 1):
		for j in range(1, n - 1):
			if ar[i][j] == ar[i - 1][j - 1] and ar[i][j] == ar[i - 1][j + 1] and (ar[i][j] == ar[i + 1][j - 1]) and (ar[i][j] == ar[i + 1][j + 1]) and (ar[i][j] == 'X'):
				c = c + 1
	print(c)


size_of_matrix = int(input())
matrix = []
for x in range(size_of_matrix):
	tmp = []
	for y in input():
		tmp.append(y)
	matrix.append(tmp)
count = 0
if size_of_matrix < 3:
	print(count)
else:
	for x in range(1, size_of_matrix - 1):
		for y in range(1, size_of_matrix - 1):
			if matrix[x][y] == 'X' and matrix[x + 1][y - 1] == 'X' and (matrix[x + 1][y + 1] == 'X') and (matrix[x - 1][y - 1] == 'X') and (matrix[x - 1][y + 1] == 'X'):
				count += 1
	print(count)


n = int(input())
l = []
c = 0
for i in range(n):
	l.append([x for x in input()])
for i in range(1, len(l) - 1):
	for j in range(1, len(l) - 1):
		if l[i][j] != '.' and l[i][j] == l[i - 1][j - 1] and (l[i + 1][j + 1] == l[i][j]) and (l[i][j] == l[i + 1][j - 1]) and (l[i][j] == l[i - 1][j + 1]):
			c = c + 1
print(c)


n = int(input())
mat = []
res = 0
for i in range(n):
	mat.append(' '.join(input()).split())
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if mat[i][j] == 'X':
			if mat[i - 1][j - 1] == 'X':
				if mat[i - 1][j + 1] == 'X':
					if mat[i + 1][j - 1] == 'X':
						if mat[i + 1][j + 1] == 'X':
							res += 1
print(res)


n = int(input())
s = []
for i in range(n):
	s.append(input())
print(sum((s[i][j] == s[i + 2][j] == s[i + 1][j + 1] == s[i][j + 2] == s[i + 2][j + 2] == 'X' for i in range(n - 2) for j in range(n - 2))))


n = int(input())
matrix = [[] for i in range(n)]
count = 0
for i in range(n):
	line = list(input())
	matrix[i] = line
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if matrix[i][j] == 'X' and matrix[i - 1][j - 1] == 'X' and (matrix[i - 1][j + 1] == 'X') and (matrix[i + 1][j - 1] == 'X') and (matrix[i + 1][j + 1] == 'X'):
			count += 1
print(count)


from sys import stdin
n = int(stdin.readline())
Matrix = []
for row in range(n):
	Matrix.append(list(stdin.readline()))
done = False
if n <= 2:
	print(0)
	done = True
count = 0
if not done:
	for i in range(1, n - 1):
		for j in range(1, n - 1):
			if Matrix[i][j] != 'X':
				continue
			elif Matrix[i - 1][j - 1] == 'X' and Matrix[i + 1][j - 1] == 'X' and (Matrix[i - 1][j + 1] == 'X') and (Matrix[i + 1][j + 1] == 'X'):
				count += 1
	print(count)


n = int(input())
m = []
for i in range(n):
	s = input()
	h = []
	for f in range(n):
		h.append(s[f])
	m.append(h)
ans = 0
for i in range(1, n - 1, 1):
	for j in range(1, n - 1, 1):
		if m[i][j] == 'X' and m[i][j] == m[i + 1][j - 1] and (m[i][j] == m[i - 1][j - 1]) and (m[i][j] == m[i - 1][j + 1]) and (m[i][j] == m[i + 1][j + 1]):
			ans += 1
print(ans)


m = int(input())
l = []
for i in range(m):
	l.append(list(input()))
ans = 0
for i in range(1, m - 1):
	for k in range(1, m - 1):
		if l[i][k] == 'X' and l[i - 1][k - 1] == 'X' and (l[i - 1][k + 1] == 'X') and (l[i + 1][k - 1] == 'X') and (l[i + 1][k + 1] == 'X'):
			ans += 1
print(ans)


m = int(input())
count = 0
cross = list()
for i in range(m):
	sline = input()
	temp = []
	for j in range(m):
		if sline[j] == '.':
			temp.append(0)
		elif sline[j] == 'X':
			temp.append(1)
	cross.append(temp)
for i in range(1, m - 1, 1):
	for j in range(1, m - 1, 1):
		if cross[i][j] == 1:
			if cross[i - 1][j - 1] == 1 and cross[i - 1][j + 1] == 1 and (cross[i + 1][j - 1] == 1) and (cross[i + 1][j + 1] == 1):
				count += 1
print(count)


l = []
n = int(input())
for k in range(n):
	l.append(input())
count = 0
for i in range(1, n - 1):
	if 'X' in l[i]:
		for j in range(1, n - 1):
			if 'X' in l[i][j] and 'X' in l[i - 1][j - 1] and ('X' in l[i - 1][j + 1]) and ('X' in l[i + 1][j + 1]) and ('X' in l[i + 1][j - 1]):
				count += 1
print(count)


n = int(input())
arr = []
for i in range(n):
	arr.append(input())
su = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if arr[i][j] == arr[i - 1][j - 1] == arr[i - 1][j + 1] == arr[i + 1][j + 1] == arr[i + 1][j - 1] == 'X':
			su += 1
print(su)


def main_function():
	n = int(input())
	lis = []
	for i in range(n):
		s = input()
		lis.append(s)
	count = 0
	for i in range(1, len(lis) - 1):
		for j in range(1, len(lis[0]) - 1):
			if lis[i][j] == 'X' and lis[i + 1][j + 1] == 'X' and (lis[i - 1][j - 1] == 'X') and (lis[i + 1][j - 1] == 'X') and (lis[i - 1][j + 1] == 'X'):
				count += 1
	return count
print(main_function())


n = int(input())
a = [[s for s in input()] for i in range(n)]
ans = 0
for i in range(n - 2):
	for j in range(n - 2):
		if a[i][j] == 'X' and a[i + 1][j + 1] == 'X' and (a[i + 2][j] == 'X') and (a[i][j + 2] == 'X') and (a[i + 2][j + 2] == 'X'):
			ans += 1
print(ans)


M = int(input())
arr = []
count = 0
for i in range(M):
	arr.append(str(input()))
for i in range(M):
	for j in range(M):
		if i != 0 and j != 0 and (i < M - 1) and (j < M - 1):
			if arr[i][j] == arr[i - 1][j - 1] == arr[i - 1][j + 1] == arr[i + 1][j - 1] == arr[i + 1][j + 1] == 'X':
				count += 1
print(count)


n = int(input().lstrip())
m = []
for _ in range(n):
	line = input().lstrip()
	m.append(line)
count = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if m[i][j] == 'X' and m[i - 1][j - 1] == 'X' and (m[i - 1][j + 1] == 'X') and (m[i + 1][j - 1] == 'X') and (m[i + 1][j + 1] == 'X'):
			count += 1
print(count)


n = int(input())
block = [list(input()) for i in range(n)]
count = 0
for i in range(n - 2):
	for j in range(n - 2):
		if block[i][j] == block[i + 1][j + 1] == block[i + 2][j + 2] == block[i][j + 2] == block[i + 2][j] == 'X':
			count += 1
print(count)


def check(a, i, j):
	if a[i - 1][j - 1] == a[i + 1][j + 1] == a[i + 1][j - 1] == a[i - 1][j + 1] == 'X':
		return 1
	else:
		return 0
n = int(input())
a = []
aa = []
for i in range(n):
	a = list(map(str, input()))
	aa.append(a)
c = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if aa[i][j] == 'X':
			if check(aa, i, j) == 1:
				c += 1
print(c)


def main():
	n = int(input())
	a = [0] * n
	for i in range(n):
		a[i] = input()
	s = 0
	for i in range(1, n - 1):
		for j in range(1, n - 1):
			if a[i][j] == 'X':
				if a[i - 1][j - 1] == 'X' and a[i + 1][j + 1] == 'X':
					if a[i - 1][j + 1] == 'X' and a[i + 1][j - 1] == 'X':
						s += 1
	print(s)
main()


m = []
d = {'X': 1, '.': 0}
crosses = 0
n = int(input())
size = n
while n:
	m.append(input())
	n -= 1
for i in range(1, size - 1):
	for j in range(1, size - 1):
		if d[m[i][j]] + d[m[i - 1][j - 1]] + d[m[i - 1][j + 1]] + d[m[i + 1][j - 1]] + d[m[i + 1][j + 1]] == 5:
			crosses += 1
print(crosses)


n = int(input())
num = 0
str0 = str(input())
if n == 1:
	print(num)
elif n == 2:
	str1 = str(input())
	print(num)
else:
	str1 = str(input())
	str2 = str(input())
	j = 1
	while j < n - 1:
		if str1[j] == str0[j - 1] == str0[j + 1] == str2[j - 1] == str2[j + 1] == 'X':
			num += 1
		j += 1
	i = 3
	while i < n:
		if i % 3 == 0:
			str0 = str(input())
			j = 1
			while j < n - 1:
				if str2[j] == str1[j - 1] == str1[j + 1] == str0[j - 1] == str0[j + 1] == 'X':
					num += 1
				j += 1
		elif i % 3 == 1:
			str1 = str(input())
			j = 1
			while j < n - 1:
				if str0[j] == str2[j - 1] == str2[j + 1] == str1[j - 1] == str1[j + 1] == 'X':
					num += 1
				j += 1
		elif i % 3 == 2:
			str2 = str(input())
			j = 1
			while j < n - 1:
				if str1[j] == str0[j - 1] == str0[j + 1] == str2[j - 1] == str2[j + 1] == 'X':
					num += 1
				j += 1
		i += 1
	print(num)


def a(x):
	return map(lambda u, v: u and v, x, x[2:])

def b(x):
	return x[1:-1]
n = int(input())
m = [list(map(lambda c: c == 'X', input())) for _ in range(n)]
print(sum(map(lambda x, y, z: sum(map(lambda t1, t2, t3: t1 and t2 and t3, a(x), b(y), a(z))), m, m[1:], m[2:])))


n = int(input())
M = []
for k in range(n):
	M = M + [input()]
p = 0
for i in range(0, n - 2):
	for j in range(0, n - 2):
		if M[i][j] == 'X' and M[i + 2][j] == 'X' and (M[i][j + 2] == 'X') and (M[i + 2][j + 2] == 'X') and (M[i + 1][j + 1] == 'X'):
			p += 1
print(p)


def main():
	n = int(input())
	m = [input() for _ in range(n)]
	cnt = 0
	for i in range(1, n - 1):
		for j in range(1, n - 1):
			cnt += m[i][j] == 'X' == m[i - 1][j - 1] == m[i + 1][j + 1] == m[i + 1][j - 1] == m[i - 1][j + 1]
	print(cnt)
main()


n = int(input())
M = []
for i in range(n):
	M.append(input())
cnt = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if M[i][j] == M[i + 1][j + 1] == M[i - 1][j + 1] == M[i + 1][j - 1] == M[i - 1][j - 1] == 'X':
			cnt += 1
print(cnt)


n = int(input())
arr = [[j for j in input()] for k in range(n)]
count = 0
for j in range(1, n - 1):
	for k in range(1, n - 1):
		if arr[j][k] == 'X' and arr[j - 1][k - 1] == 'X' and (arr[j + 1][k - 1] == 'X') and (arr[j + 1][k + 1] == 'X') and (arr[j - 1][k + 1] == 'X'):
			count += 1
print(count)


x = int(input())
z = []
t = 0
for i in range(x):
	a = input()
	z.append(a)
for i in range(x - 2):
	for j in range(x - 2):
		if z[i][j] == 'X' and z[i][j + 2] == 'X' and (z[i + 1][j + 1] == 'X') and (z[i + 2][j] == 'X') and (z[i + 2][j + 2] == 'X'):
			t = t + 1
print(t)


def check(ls, x, y):
	if ls[x - 1][y - 1] == ls[x - 1][y + 1] == ls[x + 1][y - 1] == ls[x + 1][y + 1] == 'X':
		return True
	return False
n = int(input())
a = []
ans = 0
for i in range(n):
	a.append([i for i in input()])
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if a[i][j] == 'X':
			ans += 1 if check(a, i, j) else 0
print(ans)


def crossesCount(matrix):
	count = 0
	for i in range(1, len(matrix) - 1):
		for j in range(1, len(matrix[0]) - 1):
			if matrix[i][j] == matrix[i - 1][j - 1] and matrix[i][j] == matrix[i + 1][j - 1] and (matrix[i][j] == matrix[i - 1][j + 1]) and (matrix[i][j] == matrix[i + 1][j + 1]) and (matrix[i][j] == 'X'):
				count += 1
	return count
n = int(input())
matrix = []
for _ in range(n):
	matrix.append(input())
print(crossesCount(matrix))


def is_x(n, matrix, row, col):
	if matrix[row][col] == 'X' and row > 0 and (col > 0) and (row < n - 1) and (col < n - 1):
		return matrix[row - 1][col - 1] == 'X' and matrix[row - 1][col + 1] == 'X' and (matrix[row + 1][col - 1] == 'X') and (matrix[row + 1][col + 1] == 'X')
	return False

def get_nb_x(n, matrix):
	if n < 3:
		return 0
	nb_x = 0
	for row in range(n):
		for col in range(n):
			if is_x(n, matrix, row, col):
				nb_x += 1
	return nb_x
n = int(input())
matrix = [0] * n
for row in range(n):
	matrix[row] = input().strip()
print(get_nb_x(n, matrix))


a = int(input())
l = []
for i in range(a):
	l.append(input())
count = 0
for i in range(1, a - 1):
	for j in range(1, a - 1):
		if l[i][j] == l[i - 1][j - 1] == l[i - 1][j + 1] == l[i + 1][j - 1] == l[i + 1][j + 1] == 'X':
			count = count + 1
print(count)


n = int(input())
L = []
for i in range(n):
	L.append([i for i in input()])
res = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if L[i][j] == 'X' and L[i - 1][j + 1] == 'X' and (L[i - 1][j - 1] == 'X') and (L[i + 1][j - 1] == 'X') and (L[i + 1][j + 1] == 'X'):
			res += 1
print(res)


n = int(input())
m = []
for i in range(n):
	m.append(input())
k = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if m[i][j] == 'X' and m[i - 1][j - 1] == 'X' and (m[i - 1][j + 1] == 'X') and (m[i + 1][j - 1] == 'X') and (m[i + 1][j + 1] == 'X'):
			k += 1
print(k)


n = int(input())
c = 0
a = []
for _ in range(n):
	a.append(input())
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if a[i][j] == a[i - 1][j - 1] == a[i - 1][j + 1] == a[i + 1][j - 1] == a[i + 1][j + 1] == 'X':
			c += 1
print(c)


n = int(input())
m = n
l = []
l.extend(['0' for _ in range(n + 2)])
for i in range(n):
	l.append('0')
	l.extend((x for x in input()))
	l.append('0')
l.extend(['0' for _ in range(n + 2)])
counter = 0
for u in range(n, (n + 2) * (n + 1)):
	if u % (n + 2) != 0 and (u + 1) % (n + 2) != 0:
		if l[u] == 'X' and l[u - n - 1] == 'X' and (l[u - n - 3] == 'X'):
			if l[u + n + 1] == 'X' and l[u + n + 3] == 'X':
				counter += 1
print(counter)


n = int(input())
arr = [list(input().strip()) for i in range(n)]
count = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if arr[i - 1][j - 1] == arr[i - 1][j + 1] == arr[i][j] == arr[i + 1][j - 1] == arr[i + 1][j + 1] == 'X':
			count += 1
print(count)


x = int(input())
y = []
z = 0
for i in range(x):
	y.append(input())
for i in range(1, x - 1):
	for j in range(1, x - 1):
		if y[i][j] == 'X':
			if y[i - 1][j - 1] == 'X' and y[i - 1][j + 1] == 'X':
				if y[i + 1][j - 1] == 'X' and y[i + 1][j + 1] == 'X':
					z += 1
print(z)


n = int(input())
m = [[] for r in range(n)]
for i in range(n):
	st = input()
	a = list(st)
	m[i] = a
answer = 0
for r in range(1, n - 1):
	for c in range(1, n - 1):
		if m[r][c] == m[r + 1][c + 1] == m[r + 1][c - 1] == m[r - 1][c - 1] == m[r - 1][c + 1] == 'X':
			answer += 1
print(answer)


def main():
	n = int(input())
	matrix = []
	for i in range(n):
		s = input()
		matrix.append(s)
	count = 0
	for i in range(1, n - 1):
		for j in range(1, n - 1):
			if matrix[i][j] == 'X' and matrix[i - 1][j - 1] == 'X' and (matrix[i - 1][j + 1] == 'X') and (matrix[i + 1][j - 1] == 'X') and (matrix[i + 1][j + 1] == 'X'):
				count += 1
	print(count)
main()


n = int(input(''))
arr = []
for i in range(n):
	s = input('')
	arr.append(s)
res = 0
for i in range(n):
	for j in range(n):
		if arr[i][j] == 'X':
			f = 0
			if i - 1 >= 0 and j - 1 >= 0 and (arr[i - 1][j - 1] == 'X'):
				f = f + 1
			if i - 1 >= 0 and j + 1 < n and (arr[i - 1][j + 1] == 'X'):
				f = f + 1
			if i + 1 < n and j - 1 >= 0 and (arr[i + 1][j - 1] == 'X'):
				f = f + 1
			if i + 1 < n and j + 1 < n and (arr[i + 1][j + 1] == 'X'):
				f = f + 1
			if f == 4:
				res = res + 1
print(res)


n = int(input())
M = [0 for i in range(n)]
for i in range(n):
	M[i] = input()
dx = [1, -1, 1, -1]
dy = [1, 1, -1, -1]
cnt = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		s = M[i][j]
		if s == '.':
			continue
		flag = True
		for k in range(4):
			if M[i + dx[k]][j + dy[k]] == s:
				continue
			flag = False
			break
		if flag:
			cnt += 1
print(cnt)


def ii():
	return int(input())

def ss():
	return [x for x in input()]

def si():
	return [int(x) for x in input().split()]

def mi():
	return map(int, input().split())
a = ii()
s = [[1 if i == 'X' else 0 for i in input()] for i in range(a)]
ans = 0
for i in range(1, a - 1):
	for x in range(1, a - 1):
		if s[i][x] and s[i - 1][x - 1] and s[i - 1][x + 1] and s[i + 1][x + 1] and s[i + 1][x - 1]:
			ans += 1
print(ans)


n = int(input())
l = []
ans = 0
for i in range(n):
	l.append(input())

def foo(x, y):
	if l[x][y] == l[x - 1][y - 1] == l[x - 1][y + 1] == l[x + 1][y - 1] == l[x + 1][y + 1] == 'X':
		return True
	else:
		return False
for p in range(1, n - 1):
	for q in range(1, n - 1):
		if foo(p, q):
			ans += 1
		else:
			continue
print(ans)


def main():
	n = int(input())
	matrix = []
	for _ in range(n):
		row = list(input())
		matrix.append(row)
	count = 0
	for i in range(1, n):
		for j in range(1, n - 1):
			if i - 1 >= 0 and j - 1 >= 0 and (i + 1 < n) and (j + 1 < n) and (matrix[i][j] == 'X') and (matrix[i - 1][j - 1] == 'X') and (matrix[i + 1][j + 1] == 'X') and (matrix[i - 1][j + 1] == 'X') and (matrix[i + 1][j - 1] == 'X'):
				count += 1
	print(count)
	return
main()


c = 0
n = int(input())
a = []
for i in range(n):
	a.append(input())
for i in range(1, n - 1):
	for k in range(1, n - 1):
		if a[i][k] == 'X':
			if a[i - 1][k - 1] == 'X' and a[i - 1][k + 1] == 'X' and (a[i + 1][k - 1] == 'X') and (a[i + 1][k + 1] == 'X'):
				c += 1
print(c)


n = int(input())
a = [[x == 'X' for x in input()] for _ in range(n)]
res = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if a[i][j] and a[i - 1][j - 1] and a[i - 1][j + 1] and a[i + 1][j - 1] and a[i + 1][j + 1]:
			res += 1
print(res)


n = int(input())
f = []

def checkCross(x, y):
	if f[x][y] == 'X' and f[x - 1][y - 1] == 'X' and (f[x + 1][y - 1] == 'X') and (f[x - 1][y + 1] == 'X') and (f[x + 1][y + 1] == 'X'):
		return True
	return False
for i in range(n):
	f.append([ch for ch in input()])
result = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if checkCross(i, j):
			result += 1
print(result)


n = int(input())
l = []
for i in range(n):
	l.append(input())
c = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if l[i][j] == 'X':
			if l[i - 1][j - 1] == 'X' and l[i - 1][j + 1] == 'X' and (l[i + 1][j - 1] == 'X') and (l[i + 1][j + 1] == 'X'):
				c += 1
print(c)


import sys
import math
n = int(input())
mat = []
for _ in range(n):
	asd = str(input())
	mx = list(asd)
	mat.append(mx)
con = 0
for i in range(n):
	t = mat[i]
	if i > 0:
		s = mat[i - 1]
	if i < n - 1:
		u = mat[i + 1]
	f = len(t)
	for j in range(f):
		if t[j] == 'X':
			if i - 1 >= 0 and j - 1 >= 0:
				if s[j - 1] == '.':
					continue
			else:
				continue
			if i - 1 >= 0 and j + 1 < f:
				if s[j + 1] == '.':
					continue
			else:
				continue
			if i + 1 < n and j - 1 >= 0:
				if u[j - 1] == '.':
					continue
			else:
				continue
			if i + 1 < n and j + 1 < f:
				if u[j + 1] == '.':
					continue
			else:
				continue
			con += 1
print(con)


n = int(input())
matrix = []
for i_ in range(n):
	matrix.append(list(input()))
count = 0
for i in range(1, n):
	for j in range(1, n):
		if matrix[i][j] == 'X':
			try:
				if matrix[i - 1][j - 1] == 'X' and matrix[i - 1][j + 1] == 'X' and (matrix[i + 1][j - 1] == 'X') and (matrix[i + 1][j + 1] == 'X'):
					count += 1
			except:
				pass
print(count)


c = int(input())
n = c
m = c
a = []
qq = 0
for j in range(n):
	d = []
	b = input()
	d[:0] = b
	a.append(d)
for i in range(1, n - 1):
	for j in range(1, m - 1):
		if a[i][j] == a[i - 1][j - 1] == a[i + 1][j + 1] == a[i - 1][j + 1] == a[i + 1][j - 1] == 'X':
			qq = qq + 1
print(qq)


from sys import stdin, stdout
Input = lambda : stdin.readline().strip()
Print = lambda text: stdout.write(str(text))
n = int(Input())
m = [Input() for j in range(n)]
if n < 3:
	Print(0)
else:
	ans = 0
	for i in range(1, n - 1):
		for j in range(1, n - 1):
			if m[i][j] == m[i - 1][j - 1] == m[i - 1][j + 1] == m[i + 1][j - 1] == m[i + 1][j + 1] == 'X':
				ans += 1
	Print(ans)


n = int(input())
l = [input() for i in range(n)]
f = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if l[i][j] == 'X':
			if l[i - 1][j - 1] == l[i - 1][j + 1] == l[i + 1][j - 1] == l[i + 1][j + 1] == 'X':
				f += 1
print(f)


def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(mi())
n = ii()
a = [input().strip() for i in range(n)]
ans = sum((a[i][j] == a[i - 1][j - 1] == a[i - 1][j + 1] == a[i + 1][j - 1] == a[i + 1][j + 1] == 'X' for i in range(1, n - 1) for j in range(1, n - 1)))
print(ans)


mas = []
x = 0
n = int(input())
for i in range(n):
	new_mas = []
	new_mas = list(input())
	mas.append(new_mas)
if n < 3:
	print(0)
	exit(0)
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if mas[i][j] == 'X' and mas[i - 1][j - 1] == 'X' and (mas[i + 1][j + 1] == 'X') and (mas[i - 1][j + 1] == 'X') and (mas[i + 1][j - 1] == 'X'):
			x += 1
print(x)


try:
	n = int(input())
	l = []
	b = []
	c = 0
	if n < 3:
		print(0)
	else:
		for i in range(0, n):
			m = input()
			l = list(m)
			b.append(l)
		for i in range(0, n - 2):
			for j in range(0, n - 2):
				if b[i][j] == 'X' and b[i][j + 2] == 'X' and (b[i + 1][j + 1] == 'X') and (b[i + 2][j] == 'X') and (b[i + 2][j + 2] == 'X'):
					c += 1
		print(c)
except:
	pass


def crosses(lst):
	count = 0
	for i in range(1, len(lst)):
		for j in range(1, len(lst)):
			if i + 1 < len(lst) and j + 1 < len(lst):
				count += lst[i][j] == 'X' and lst[i - 1][j - 1] == 'X' and (lst[i - 1][j + 1] == 'X') and (lst[i + 1][j - 1] == 'X') and (lst[i + 1][j + 1] == 'X')
	return count
n = int(input())
a = list()
for i in range(n):
	s = input()
	a.append(list(s))
print(crosses(a))


n = int(input())
mat = []
for _ in range(n):
	mat.append(list(input().strip()))

def is_cross(mat, i, j):
	if mat[i - 1][j - 1] == mat[i - 1][j + 1] == mat[i + 1][j + 1] == mat[i + 1][j - 1] == mat[i][j] == 'X':
		return True
	return False
count = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if is_cross(mat, i, j):
			count += 1
print(count)


n = eval(input())
ls = []
a = 0
for i in range(n):
	x = input()
	ls.append(x)
for i in range(n - 2):
	for k in range(n - 2):
		if ls[i][k] == ls[i][k + 2] == ls[i + 1][k + 1] == ls[i + 2][k] == ls[i + 2][k + 2] == 'X':
			a += 1
print(a)


n = int(input())
field = [input() for _ in range(n)]
cross = [(0, 0), (0, 2), (1, 1), (2, 0), (2, 2)]

def has_cross(field, i, j):
	return all((field[i + di][j + dj] == 'X' for (di, dj) in cross))
print(sum((has_cross(field, i, j) for i in range(n - 2) for j in range(n - 2))))


n = int(input())
M = []
for j in range(0, n):
	st = input()
	M.append([st[k] for k in range(0, n)])
k = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if M[i][j] == 'X' and M[i - 1][j - 1] == 'X' and (M[i - 1][j + 1] == 'X') and (M[i + 1][j - 1] == 'X') and (M[i + 1][j + 1] == 'X'):
			k += 1
print(k)


n = int(input())
arr = [0] * n
for i in range(n):
	arr[i] = input()
cnt = 0
if n < 3:
	print(0)
	exit()
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if arr[i][j] == 'X' and arr[i - 1][j - 1] == 'X' and (arr[i - 1][j + 1] == 'X') and (arr[i + 1][j + 1] == 'X') and (arr[i + 1][j - 1] == 'X'):
			cnt += 1
print(cnt)


a = int(input())
b = []
n = 0
for i in range(a):
	b.append(input())
for i in range(1, a - 1):
	if a < 3:
		break
	for j in range(1, a - 1):
		if b[i][j] == 'X' and b[i + 1][j + 1] == 'X' and (b[i - 1][j + 1] == 'X') and (b[i + 1][j - 1] == 'X') and (b[i - 1][j - 1] == 'X'):
			n += 1
print(n)


n = int(input())
mtr = []
for _ in range(n):
	mtr.append(input().strip())
cnt = 0
for r in range(1, n - 1):
	for c in range(1, n - 1):
		if mtr[r][c] == mtr[r - 1][c - 1] == mtr[r - 1][c + 1] == mtr[r + 1][c - 1] == mtr[r + 1][c + 1] == 'X':
			cnt += 1
print(cnt)


import sys
n = int(input())
arr = []
for i in range(n):
	arr.append(input())
if n == 2:
	print(0)
	sys.exit()
count = 0
for i in range(1, len(arr) - 1):
	for j in range(1, len(arr[i]) - 1):
		if arr[i][j] == 'X' and arr[i - 1][j - 1] == 'X' and (arr[i - 1][j + 1] == 'X') and (arr[i + 1][j - 1] == 'X') and (arr[i + 1][j + 1] == 'X'):
			count += 1
print(count)


def check(i, j, a):
	if a[i][j] == 'X' and a[i][j] == a[i + 1][j + 1] and (a[i + 1][j + 1] == a[i - 1][j + 1]) and (a[i + 1][j + 1] == a[i - 1][j - 1]) and (a[i + 1][j + 1] == a[i + 1][j - 1]):
		return 1
	else:
		return 0
a = []
b = int(input())
z = 0
for i in range(b):
	l = list(input())
	a.append(l)
for i in range(1, b - 1):
	for j in range(1, b - 1):
		f = check(i, j, a)
		z += f
print(z)


def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(mi())
n = ii()
s = []
for i in range(n):
	s.append(input())
c = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if s[i][j] == 'X' and s[i - 1][j - 1] == 'X' and (s[i - 1][j + 1] == 'X') and (s[i + 1][j - 1] == 'X') and (s[i + 1][j + 1] == 'X'):
			c += 1
print(c)


n = int(input())
grid = [input() for _ in range(n)]
count = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if grid[i][j] != 'X':
			continue
		if grid[i - 1][j - 1] != 'X':
			continue
		if grid[i - 1][j + 1] != 'X':
			continue
		if grid[i + 1][j - 1] != 'X':
			continue
		if grid[i + 1][j + 1] != 'X':
			continue
		count += 1
print(count)


n = int(input())
list1 = [{0 for i in range(n)} for j in range(n)]
for i in range(n):
	list1[i] = input()
count = 0
if n <= 2:
	print(0)
else:
	for i in range(1, n - 1):
		for j in range(1, n - 1):
			if list1[i][j] == 'X':
				if list1[i - 1][j - 1] == list1[i + 1][j + 1] == list1[i - 1][j + 1] == list1[i + 1][j - 1] == 'X':
					count = count + 1
	print(count)


def cross(n, q):
	c = str(str(q).split()).count('X')
	cnt = 0
	for i in range(1, n - 1):
		for j in range(1, n - 1):
			if q[i][j] == 'X' and q[i - 1][j - 1] == 'X' and (q[i + 1][j - 1] == 'X') and (q[i - 1][j + 1] == 'X') and (q[i + 1][j + 1] == 'X'):
				cnt += 1
	return 0 if c < 5 else cnt
n = int(input())
q = []
for i in range(0, n):
	b = [i for i in input().split()]
	q.extend(b)
print(cross(n, q))


n = int(input())
grid = [input() for _ in range(n)]
total = 0
if n <= 2:
	print(total)
	exit()
for r in range(1, n - 1):
	for c in range(1, n - 1):
		if grid[r][c] != 'X':
			continue
		if grid[r - 1][c - 1] == grid[r - 1][c + 1] == grid[r + 1][c - 1] == grid[r + 1][c + 1] == 'X':
			total += 1
print(total)


s = int(input())
M = [list(input()) for i in range(s)]
count = 0
coords = [(-1, -1), (-1, 1), (1, -1), (1, 1)]
for i in range(1, s - 1):
	for j in range(1, s - 1):
		if M[i][j] == 'X':
			f = True
			for c in coords:
				if M[i + c[0]][j + c[1]] != 'X':
					f = False
					break
			if f:
				count += 1
print(count)


n = int(input())
x = []
for i in range(n):
	x.append(list(map(str, input())))
if n < 3:
	print('0')
else:
	c = 0
	for i in range(1, n - 1):
		for j in range(1, n - 1):
			if x[i][j] == x[i - 1][j - 1] == x[i - 1][j + 1] == x[i + 1][j - 1] == x[i + 1][j + 1] == 'X':
				c = c + 1
	print(c)


n = int(input())
ai = [input() for i in range(n)]
ans = 0
for i in range(n - 2):
	for j in range(n - 2):
		if ai[i][j] == ai[i + 1][j + 1] and ai[i][j] == ai[i + 2][j + 2] and (ai[i][j] == 'X') and (ai[i][j] == ai[i + 2][j]) and (ai[i][j] == ai[i][j + 2]):
			ans += 1
print(ans)


n = int(input())
arr = ['.' * (n + 2)] + ['.' + input() + '.' for i in range(n)] + ['.' * (n + 2)]
ans = 0
for i in range(1, n + 1):
	for j in range(1, n + 1):
		if arr[i][j] == arr[i - 1][j - 1] == arr[i - 1][j + 1] == arr[i + 1][j - 1] == arr[i + 1][j + 1] == 'X':
			ans += 1
print(ans)


def main():
	n = int(input())
	data = []
	for i in range(n):
		data.append(input())
	c = 0
	for i in range(1, n - 1):
		for j in range(1, n - 1):
			res = []
			res.append(data[i][j])
			res.append(data[i - 1][j - 1])
			res.append(data[i - 1][j + 1])
			res.append(data[i + 1][j - 1])
			res.append(data[i + 1][j + 1])
			if all([x == 'X' for x in res]):
				c += 1
	print(c)
main()


n = int(input())
m = []
count = 0
for x in range(n):
	alpha = input()
	beta = list(alpha)
	m.append(beta)
for loop in range(n):
	for loop1 in range(n):
		if m[loop][loop1] == 'X':
			if loop - 1 >= 0 and loop1 - 1 >= 0 and (loop + 1 < n) and (loop1 + 1 < n):
				if m[loop - 1][loop1 - 1] == 'X' and m[loop + 1][loop1 - 1] == 'X' and (m[loop + 1][loop1 + 1] == 'X') and (m[loop - 1][loop1 + 1] == 'X'):
					count = count + 1
print(count)


n = int(input())
s = []
w = 0
for i in range(0, n):
	s.append(input())
if n == 1 or n == 2:
	print(0)
else:
	for i in range(1, n - 1):
		for j in range(1, n - 1):
			if s[i][j] == s[i - 1][j - 1] == s[i - 1][j + 1] == s[i + 1][j - 1] == s[i + 1][j + 1] == 'X':
				w += 1
	print(w)


def is_cross(M, i, j):
	if M[i][j] == M[i - 1][j - 1] == M[i - 1][j + 1] == M[i + 1][j - 1] == M[i + 1][j + 1] == 'X':
		return True
	else:
		return False
nb = int(input())
M = [[''] * nb for _ in range(nb)]
for l in range(nb):
	line = input()
	for c in range(nb):
		M[l][c] = line[c]
nbC = 0
for l in range(1, nb - 1):
	for c in range(1, nb - 1):
		if is_cross(M, l, c):
			nbC += 1
print(nbC)


n = int(input())
matrix = [0] * n
for i in range(n):
	entrada = str(input())
	matrix[i] = list(entrada)
crosses_counter = 0

def M(i, j):
	return matrix[i][j]
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if M(i, j) == M(i - 1, j - 1) == M(i - 1, j + 1) == M(i + 1, j - 1) == M(i + 1, j + 1) == 'X':
			crosses_counter += 1
print(crosses_counter)


a = []
n = int(input())
for i in range(n):
	a.append(input())
c = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if a[i][j] == 'X' and a[i - 1][j - 1] == 'X' and (a[i - 1][j + 1] == 'X') and (a[i + 1][j - 1] == 'X') and (a[i + 1][j + 1] == 'X') or (a[i][j] == 'x' and a[i - 1][j - 1] == 'x' and (a[i - 1][j + 1] == 'x') and (a[i + 1][j - 1] == 'x') and (a[i + 1][j + 1] == 'x')):
			c += 1
print(c)


n = int(input())
grid = []
for i in range(n):
	grid.append(input())
tt = 0
for i in range(1, n - 1):
	for a in range(1, n - 1):
		if grid[i][a] == grid[i - 1][a - 1] == grid[i - 1][a + 1] == grid[i + 1][a - 1] == grid[i + 1][a + 1] == 'X':
			tt += 1
print(tt)


n = int(input())
l = []
for i in range(n):
	x = input()
	l.append(x)
cnt = 0
if n > 2:
	for i in range(1, n - 1):
		for j in range(1, n - 1):
			if l[i][j] == 'X' and l[i + 1][j + 1] == 'X' and (l[i - 1][j - 1] == 'X') and (l[i - 1][j + 1] == 'X') and (l[i + 1][j - 1] == 'X'):
				cnt += 1
print(cnt)


n = int(input())
a = []
for i in range(n):
	a.append(input())
if n < 3:
	print(0)
else:
	c = 0
	for i in range(1, n - 1):
		for j in range(1, n - 1):
			if a[i][j] == 'X' and a[i - 1][j - 1] == 'X' and (a[i - 1][j + 1] == 'X') and (a[i + 1][j - 1] == 'X') and (a[i + 1][j + 1] == 'X'):
				c += 1
	print(c)


n = int(input())
A = [list(input()) for i in range(n)]
cnt = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if A[i][j] == 'X' == A[i - 1][j - 1] == A[i + 1][j - 1] == A[i + 1][j + 1] == A[i - 1][j + 1]:
			cnt += 1
print(cnt)


n = int(input())
ar = [[i for i in input()] for j in range(n)]

def iscross(i, j):
	if ar[i - 1][j - 1] == 'X' and ar[i - 1][j + 1] == 'X' and (ar[i + 1][j + 1] == 'X') and (ar[i + 1][j - 1] == 'X') and (ar[i][j] == 'X'):
		return True
	return False
c = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if iscross(i, j):
			c += 1
print(c)


n = int(input())
matrix = [list(input()) for _ in range(n)]
crosses_counter = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if matrix[i][j] == matrix[i - 1][j - 1] == matrix[i - 1][j + 1] == matrix[i - 1][j - 1] == matrix[i + 1][j + 1] == matrix[i + 1][j - 1] == 'X':
			crosses_counter += 1
print(crosses_counter)


q = int(input())
matrix = dict()
for i in range(q):
	row = input()
	for (j, value) in enumerate(row):
		matrix[i, j] = value
counter = 0
for i in range(q):
	for j in range(q):
		if i > 0 and j > 0 and (i <= q - 2) and (j <= q - 2) and (matrix[i - 1, j - 1] == 'X') and (matrix[i - 1, j + 1] == 'X') and (matrix[i + 1, j - 1] == 'X') and (matrix[i + 1, j + 1] == 'X') and (matrix[i, j] == 'X'):
			counter += 1
print(counter)


n = int(input())
S = []
for i in range(n):
	s = input()
	S.append(s)
ans = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if S[i][j] == 'X':
			a = 0
			if S[i - 1][j - 1] == 'X':
				a += 1
			if S[i - 1][j + 1] == 'X':
				a += 1
			if S[i + 1][j - 1] == 'X':
				a += 1
			if S[i + 1][j + 1] == 'X':
				a += 1
			if a == 4:
				ans += 1
print(ans)


import sys
import math
import collections
import operator as op
from collections import deque
from math import gcd, inf, sqrt, pi, cos, sin, ceil, log2
from bisect import bisect_right, bisect_left
from functools import reduce
from sys import stdin, stdout, setrecursionlimit
setrecursionlimit(2 ** 20)

def factorial(n):
	if n == 0:
		return 1
	return n * factorial(n - 1)

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom

def prime_factors(n):
	i = 2
	factors = []
	while i * i <= n:
		if n % i:
			i += 1
		else:
			n //= i
			factors.append(i)
	if n > 1:
		factors.append(n)
	return len(set(factors))

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def factors(n):
	return list(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))
MOD = 1000000007
PMOD = 998244353
T = 1
for _ in range(T):
	n = int(stdin.readline())
	a = []
	if n < 3:
		print(0)
		continue
	for i in range(n):
		a.append(str(stdin.readline().strip('\n')))
	ans = 0
	for i in range(1, n - 1):
		for j in range(1, n - 1):
			if a[i][j] == 'X' and a[i - 1][j - 1] == 'X' and (a[i - 1][j + 1] == 'X') and (a[i + 1][j - 1] == 'X') and (a[i + 1][j + 1] == 'X'):
				ans += 1
	print(ans)


n = int(input())
M = [[False for i in range(n)] for j in range(n)]
for j in range(n):
	line = input()
	for (i, s) in enumerate(line):
		M[i][j] = s
k = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if M[i][j] == M[i - 1][j - 1] == M[i - 1][j + 1] == M[i + 1][j - 1] == M[i + 1][j + 1] == 'X':
			k += 1
print(k)


n = int(input())
row = ['.' * (n + 2)]
table = row + ['.' + input() + '.' for i in range(0, n)] + row
res = 0
lst = [(-1, -1), (-1, 1), (1, 1), (1, -1), (0, 0)]
for i in range(1, n + 1):
	for j in range(1, n + 1):
		ok = True
		for (_i, _j) in lst:
			if table[i + _i][j + _j] != 'X':
				ok = False
		if ok:
			res += 1
print(res)


c = 0
n = int(input())
List = []
for x in range(n):
	List.append(list(input()))
for y in range(1, n - 1):
	for x in range(1, n - 1):
		if List[y][x] == List[y - 1][x - 1] == List[y - 1][x + 1] == List[y + 1][x - 1] == List[y + 1][x + 1] == 'X':
			c += 1
print(c)


a = int(input())
ar = [input() for i in range(a)]
a -= 1
rez = 0
for i in range(1, a):
	for j in range(1, a):
		if ar[i][j] == ar[i + 1][j + 1] == ar[i - 1][j + 1] == ar[i - 1][j - 1] == ar[i + 1][j - 1] == 'X':
			rez += 1
print(rez)


def isCross(a, matrix):
	n = len(matrix)
	(i, j) = a
	for (x, y) in [(i - 1, j + 1), (i - 1, j - 1), (i + 1, j + 1), (i + 1, j - 1)]:
		if matrix[x][y] != 'X':
			return False
	return True
n = int(input())
matrix = [input() for _ in range(n)]
cnt = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if matrix[i][j] == 'X' and isCross((i, j), matrix):
			cnt += 1
print(cnt)


n = int(input())
m = []
for _ in range(n):
	m.append(input())
ans = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if m[i][j] == 'X' and m[i - 1][j - 1] == 'X' and (m[i - 1][j + 1] == 'X') and (m[i + 1][j - 1] == 'X') and (m[i + 1][j + 1] == 'X'):
			ans += 1
print(ans)


n = int(input())
arr = []
for i in range(n):
	arr.append(list(input()))
count = 0
if n <= 2:
	print(0)
else:
	for i in range(1, n - 1):
		for j in range(1, n - 1):
			if arr[i][j] == arr[i - 1][j - 1] == arr[i - 1][j + 1] == arr[i + 1][j - 1] == arr[i + 1][j + 1] == 'X':
				count += 1
	print(count)


import sys

def read_matrix():
	arr = []
	for line in sys.stdin:
		arr.append(line)
	return arr[1:]

def fix_x():
	arr = read_matrix()
	if len(arr) < 3:
		return 0
	s = 0
	for i in range(1, len(arr) - 1):
		for j in range(1, len(arr[0])):
			if arr[i][j] == 'X' and arr[i - 1][j - 1] == 'X' and (arr[i - 1][j + 1] == 'X') and (arr[i + 1][j - 1] == 'X') and (arr[i + 1][j + 1] == 'X'):
				s += 1
	return s
print(fix_x())


class CodeforcesTask1106ASolution:

	def __init__(self):
		self.result = ''
		self.n = 0
		self.matrix = []

	def read_input(self):
		self.n = int(input())
		for x in range(self.n):
			self.matrix.append(input())

	def process_task(self):
		crosses = 0
		for y in range(1, self.n - 1):
			for x in range(1, self.n - 1):
				if self.matrix[y][x] == 'X':
					if self.matrix[y - 1][x - 1] == 'X':
						if self.matrix[y - 1][x + 1] == 'X':
							if self.matrix[y + 1][x - 1] == 'X':
								if self.matrix[y + 1][x + 1] == 'X':
									crosses += 1
		self.result = str(crosses)

	def get_result(self):
		return self.result
Solution = CodeforcesTask1106ASolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


a = int(input())
ma = []
for i in range(a):
	ma.append(input())
s = 0
for i in range(1, a - 1):
	for j in range(1, a - 1):
		if ma[i][j] == 'X':
			if ma[i + 1][j + 1] == 'X' and ma[i + 1][j - 1] == 'X' and (ma[i - 1][j - 1] == 'X') and (ma[i - 1][j + 1] == 'X'):
				s += 1
print(s)


n = int(input())
a = []
for i in range(n):
	a.append(list(input()))
ans = 0
if n < 3:
	print(0)
	exit(0)
for i in range(1, n - 1):
	for j in range(1, n - 1):
		l = [a[i][j], a[i - 1][j - 1], a[i - 1][j + 1], a[i + 1][j - 1], a[i + 1][j + 1]]
		s = list(set(l))
		if len(s) == 1 and s[0] == 'X':
			ans += 1
print(ans)


n = int(input())
mat = []
for i in range(n):
	mat.append(list(input()))

def isvalid(i, j):
	return i >= 0 and i < n and (j >= 0) and (j < n) and (mat[i][j] == 'X')
cnt = 0
for i in range(n):
	for j in range(n):
		if mat[i][j] == 'X' and isvalid(i - 1, j - 1) and isvalid(i - 1, j + 1) and isvalid(i + 1, j - 1) and isvalid(i + 1, j + 1):
			cnt += 1
print(cnt)


n = int(input())
M = [0] * n
ans = 0
for i in range(n):
	s = input()
	M[i] = list(s)
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if M[i][j] == M[i - 1][j - 1] == M[i - 1][j + 1] == M[i + 1][j - 1] == M[i + 1][j + 1] == 'X':
			ans += 1
print(ans)


import sys

def main():
	(n, *s) = sys.stdin.read().strip().split('\n')
	(c, t) = (0, [(-1, 1), (-1, -1), (1, 1), (1, -1), (0, 0)])
	for i in range(1, int(n) - 1):
		for j in range(1, int(n) - 1):
			c += all((s[i + m][j + n] == 'X' for (m, n) in t))
	return c
print(main())


n = int(input())
m = []
for i in range(n):
	s = [1 if tmp == 'X' else 0 for tmp in input().strip()]
	m.append(s)
x = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		dx = m[i][j]
		for d1 in (-1, 1):
			for d2 in (-1, 1):
				dx *= m[i + d1][j + d2]
		x += dx
print(x)


(s, ls, cs) = (int(input()), [], 0)
for _ in range(s):
	ls.append([x == 'X' for x in input()])
	if _ > 1:
		for i in range(2, s):
			if ls[_][i] and ls[_][i - 2] and ls[_ - 1][i - 1] and ls[_ - 2][i] and ls[_ - 2][i - 2]:
				cs += 1
print(cs)


n = int(input())
matrix = []
for i in range(n):
	matrix.append([x for x in input()])
count = 0
for i in range(n):
	for j in range(n):
		if j + 1 < n and i + 1 < n and (j - 1 > -1) and (i - 1 > -1):
			count += matrix[i][j] == matrix[i - 1][j - 1] == matrix[i - 1][j + 1] == matrix[i + 1][j - 1] == matrix[i + 1][j + 1] == 'X'
print(count)


n = int(input())
s = []
for i in range(n):
	t = input()
	s.append(t)
ans = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if s[i - 1][j - 1] == 'X' and s[i - 1][j + 1] == 'X' and (s[i + 1][j - 1] == 'X') and (s[i + 1][j + 1] == 'X') and (s[i][j] == 'X'):
			ans += 1
print(ans)


n = int(input())
l = [list(input().strip()) for i in range(n)]
cou = 0
for i in range(n):
	for j in range(n):
		if l[i][j] == 'X':
			if i - 1 >= 0 and j - 1 >= 0 and (i + 1 < n) and (j + 1 < n) and (l[i - 1][j - 1] == 'X' and l[i - 1][j + 1] == 'X' and (l[i + 1][j - 1] == 'X') and (l[i + 1][j + 1] == 'X')):
				cou += 1
print(cou)


num = int(input())
a = []
count = 0
for i in range(num):
	a += [input()]
for i in range(1, num - 1):
	for j in range(1, num - 1):
		if a[i - 1][j - 1] == 'X' and a[i - 1][j + 1] == 'X' and (a[i + 1][j - 1] == 'X') and (a[i + 1][j + 1] == 'X') and (a[i][j] == 'X'):
			count += 1
print(count)


n = int(input())
m = []
for _ in range(n):
	tmp = input()
	m.append(tmp)
res = 0

def check(i, j):
	return m[i - 1][j - 1] == 'X' and m[i - 1][j + 1] == 'X' and (m[i + 1][j - 1] == 'X') and (m[i + 1][j + 1] == 'X')
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if m[i][j] == 'X' and check(i, j):
			res += 1
print(res)


m = list()
n = int(input())
for _ in range(n):
	m.append(input())
cnt = 0
for ci in range(1, n - 1):
	for cj in range(1, n - 1):
		found = m[ci][cj] == 'X' and m[ci - 1][cj - 1] == 'X' and (m[ci - 1][cj + 1] == 'X') and (m[ci + 1][cj - 1] == 'X') and (m[ci + 1][cj + 1] == 'X')
		cnt += 1 if found else 0
print(cnt)


def mi():
	return map(int, input().split())
n = int(input())
a = [0] * n
for i in range(n):
	a[i] = list(input())
cnt = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if a[i][j] == 'X' and a[i - 1][j - 1] == 'X' and (a[i + 1][j - 1] == 'X') and (a[i - 1][j + 1] == 'X') and (a[i + 1][j + 1] == 'X'):
			cnt += 1
print(cnt)


n = int(input())
m = [input() for _ in [0] * n]
print(sum((m[i][j] == m[i][j + 2] == m[i + 1][j + 1] == m[i + 2][j] == m[i + 2][j + 2] == 'X' for i in range(n - 2) for j in range(n - 2))))


from sys import stdin, stdout
from itertools import combinations
from collections import defaultdict

def listIn():
	return list(map(int, stdin.readline().strip().split()))

def stringListIn():
	return [x for x in stdin.readline().split()]

def intIn():
	return int(stdin.readline())

def stringIn():
	return stdin.readline()
n = intIn()
count = 0
arr = []
for i in range(n):
	temp = list(stringIn())
	arr.append(temp)
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if arr[i][j] == arr[i - 1][j - 1] == arr[i - 1][j + 1] == arr[i + 1][j - 1] == arr[i + 1][j + 1] == 'X':
			count += 1
print(count)


n = int(input())
if n < 3:
	print('0')
else:
	m = []
	s = 0
	for i in range(0, n):
		a = list(input())
		m.append(a)
	for i in range(0, n - 2):
		for j in range(0, n - 2):
			if m[i][j] == 'X' and m[i][j + 2] == 'X' and (m[i + 1][j + 1] == 'X') and (m[i + 2][j] == 'X') and (m[i + 2][j + 2] == 'X'):
				s = s + 1
	print(s)


n = int(input())
grid = []
for i in range(n):
	grid.append(list(input()))
count = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if grid[i][j] == grid[i + 1][j + 1] == grid[i + 1][j - 1] == grid[i - 1][j + 1] == grid[i - 1][j - 1] == 'X':
			count += 1
print(count)


n = int(input())
M = [input() for i in range(n)]
cross_count = 0
for i in range(n):
	for j in range(n):
		if i == 0 or j == 0 or i == n - 1 or (j == n - 1):
			continue
		if M[i][j] == M[i - 1][j - 1] == M[i + 1][j - 1] == M[i - 1][j + 1] == M[i + 1][j + 1] == 'X':
			cross_count += 1
print(cross_count)


a = int(input())
S = []
k = 0
for i in range(a):
	S.append(input())
for i in range(1, a - 1):
	for j in range(1, a - 1):
		if S[i][j] == S[i + 1][j + 1] == S[i - 1][j + 1] == S[i + 1][j - 1] == S[i - 1][j - 1] == 'X':
			k += 1
print(k)


n = int(input())
matrix = []
for i in range(n):
	row = input().lower()
	matrix.append(list(row))
crosses = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if matrix[i][j] == 'x' and matrix[i - 1][j - 1] == 'x' and (matrix[i - 1][j + 1] == 'x') and (matrix[i + 1][j - 1] == 'x') and (matrix[i + 1][j + 1] == 'x'):
			crosses += 1
print(crosses)


n = int(input())
m = [[c for c in list(input())] for _ in range(n)]
ans = 0
for r in range(1, n - 1):
	for c in range(1, n - 1):
		if m[r][c] == m[r - 1][c - 1] == m[r - 1][c + 1] == m[r + 1][c - 1] == m[r + 1][c + 1] == 'X':
			ans += 1
print(ans)


Size = int(input())
Matrix = list()
if Size < 3:
	print(0)
	exit()
for i in range(Size):
	IN = list(input())
	Matrix.append(IN)
Count = 0
for i in range(1, Size - 1):
	for j in range(1, Size - 1):
		if Matrix[i][j] == 'X' and Matrix[i][j] == Matrix[i - 1][j - 1] and (Matrix[i][j] == Matrix[i - 1][j + 1]) and (Matrix[i + 1][j - 1] == Matrix[i][j]) and (Matrix[i][j] == Matrix[i + 1][j + 1]):
			Count += 1
print(Count)


n = int(input())
l = []
counter = 0
for i in range(n):
	l.append(input())
for i in range(n):
	if i == 0 or i == n - 1:
		continue
	for j in range(n):
		if j == 0 or j == n - 1:
			continue
		if l[i][j] == l[i - 1][j - 1] == l[i - 1][j + 1] == l[i + 1][j - 1] == l[i + 1][j + 1] == 'X':
			counter += 1
print(counter)


n = int(input())
matrix_array = []
for i in range(0, n):
	next = input()
	matrix_array.append(next)
matrix_array1 = [[0] * n for _ in range(n)]
for i in range(0, n):
	for j in range(0, n):
		matrix_array1[i][j] = matrix_array[i][j]
count = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if matrix_array1[i][j] == 'X' and matrix_array1[i - 1][j - 1] == 'X' and (matrix_array1[i + 1][j - 1] == 'X') and (matrix_array1[i - 1][j + 1] == 'X') and (matrix_array1[i + 1][j + 1] == 'X'):
			count = count + 1
print(count)


n = int(input())
matrix = []
for _ in range(n):
	matrix.append(input())
counter = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if matrix[i][j] == 'X' and matrix[i - 1][j - 1] == 'X' and (matrix[i - 1][j + 1] == 'X') and (matrix[i + 1][j - 1] == 'X') and (matrix[i + 1][j + 1] == 'X'):
			counter += 1
print(counter)


m = int(input())
matrix = []
for i in range(m):
	data = input()
	matrix.append(data)
countX = 0
for i in range(1, m - 1):
	for j in range(1, m - 1):
		if matrix[i][j] == matrix[i - 1][j - 1] == matrix[i - 1][j + 1] == matrix[i + 1][j - 1] == matrix[i + 1][j + 1] == 'X':
			countX += 1
print(countX)


n = int(input())
M = []
count = 0
for i in range(n):
	a = input()
	M.append(a)
for j in range(1, n - 1):
	for k in range(1, n - 1):
		if M[j][k] == M[j - 1][k - 1] == M[j - 1][k + 1] == M[j + 1][k - 1] == M[j + 1][k + 1] == 'X':
			count += 1
print(count)


from sys import stdin

def main():
	N = int(input())
	M = [input() for _ in [0] * N]
	ans = 0
	for i in range(1, N - 1):
		for j in range(1, N - 1):
			if all((M[i][j] == 'X', M[i - 1][j - 1] == 'X', M[i - 1][j + 1] == 'X', M[i + 1][j - 1] == 'X', M[i + 1][j + 1] == 'X')):
				ans += 1
	print(ans)
input = lambda : stdin.readline().rstrip()
main()


import os
import sys
from io import BytesIO, IOBase
import math

def main():
	n = int(input())
	a = [input() for x in range(n)]
	print(sum([a[x][y] == 'X' and a[x][y + 2] == 'X' and (a[x + 1][y + 1] == 'X') and (a[x + 2][y] == 'X') and (a[x + 2][y + 2] == 'X') for x in range(n - 2) for y in range(n - 2)]))
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


from sys import stdin, stdout
from collections import defaultdict, Counter
from bisect import bisect, bisect_left
import math
from itertools import permutations
I = stdin.readline
n = int(I())
arr = []
for _ in range(n):
	row = I().rstrip()
	arr.append(row)
count = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if arr[i][j] == arr[i - 1][j - 1] and arr[i - 1][j + 1] == arr[i][j]:
			if arr[i + 1][j - 1] == arr[i][j] and arr[i][j] == arr[i + 1][j + 1]:
				if arr[i][j] == 'X':
					count += 1
print(count)


n = int(input())
p = []
for i in range(n):
	a = str(input())
	p.append(a)
c = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if p[i][j] == p[i - 1][j - 1] == p[i - 1][j + 1] == p[i + 1][j - 1] == p[i + 1][j + 1] == 'X':
			c = c + 1
print(c)


n = int(input())
a = [['.' for i in range(0, n + 2)] for j in range(0, n + 2)]
for i in range(1, n + 1):
	s = str(input())
	for j in range(1, n + 1):
		a[i][j] = s[j - 1]
k = 0
for i in range(1, n + 1):
	for j in range(1, n + 1):
		if a[i][j] == a[i - 1][j - 1] == a[i - 1][j + 1] == a[i + 1][j - 1] == a[i + 1][j + 1] == 'X':
			k += 1
print(k)


from sys import stdin, exit
n = int(input())
if n <= 2:
	print(0)
	exit()
l = stdin.read().splitlines()
dx = [0, 1, 1, -1, -1]
dy = [0, -1, 1, -1, 1]
ans = 0
for y in range(1, n - 1):
	for x in range(1, n - 1):
		if all((l[y + dy[i]][x + dx[i]] == 'X' for i in range(5))):
			ans += 1
print(ans)


n = int(input())
matrix = list()
for i in range(n):
	temp = input()
	l = list()
	for j in temp:
		l.append(j)
	matrix.append(l)
if n < 3:
	print(0)
else:
	count = 0
	for i in range(1, n - 1):
		for j in range(1, n - 1):
			if matrix[i][j] == 'X' and matrix[i - 1][j - 1] == 'X' and (matrix[i - 1][j + 1] == 'X') and (matrix[i + 1][j - 1] == 'X') and (matrix[i + 1][j + 1] == 'X'):
				count += 1
	print(count)


a = list()
n = int(input())
res = 0
for i in range(n):
	a.append(input())
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if a[i][j] == a[i - 1][j - 1] == a[i - 1][j + 1] == a[i + 1][j - 1] == a[i + 1][j + 1] == 'X':
			res += 1
print(res)


n = int(input())
dic = {}
for i in range(n):
	x = input()
	chars = list(x)
	for j in range(n):
		dic[i + 1, j + 1] = chars[j]
number = 0
for i in range(2, n):
	for j in range(2, n):
		if 'X' == dic[i, j] == dic[i - 1, j - 1] == dic[i - 1, j + 1] == dic[i + 1, j - 1] == dic[i + 1, j + 1]:
			number += 1
print(number)


N = int(input())
L = []
count = 0
for i in range(N):
	L.append(list(input()))
for j in range(1, N - 1):
	for k in range(1, N - 1):
		if L[j][k] == 'X' and L[j - 1][k - 1] == 'X' and (L[j + 1][k + 1] == 'X') and (L[j + 1][k - 1] == 'X') and (L[j - 1][k + 1] == 'X'):
			count += 1
print(count)


n = int(input())
cnt = 0
m = []
bf = ' ' * n
m.append(bf)
for i in range(n):
	bf = ''
	st = input()
	bf += ' ' + st + ' '
	m.append(bf)
bf = ' ' * n
m.append(bf)
for i in range(1, n):
	for j in range(1, n):
		if m[i][j] == 'X':
			if m[i + 1][j + 1] == 'X':
				if m[i - 1][j - 1] == 'X':
					if m[i - 1][j + 1] == 'X':
						if m[i + 1][j - 1] == 'X':
							cnt += 1
print(cnt)


n = int(input())
mat = []
result = 0
for _ in range(n):
	sat = [j for j in input()]
	mat.append(sat)
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if mat[i][j] == 'X':
			if mat[i - 1][j - 1] == 'X' and mat[i - 1][j + 1] == 'X' and (mat[i + 1][j - 1] == 'X') and (mat[i + 1][j + 1] == 'X'):
				result += 1
print(result)


n = int(input())
arr = [input() for i in range(n)]

def check(arr, i, j):
	l = len(arr)
	if i - 1 < 0 or i + 1 >= l:
		return False
	if j - 1 < 0 or j + 1 >= l:
		return False
	if arr[i][j] == arr[i - 1][j - 1] == arr[i - 1][j + 1] == arr[i + 1][j - 1] == arr[i + 1][j + 1] == 'X':
		return True
	else:
		return False
result = 0
for i in range(n):
	for j in range(n):
		if arr[i][j] == 'X':
			if check(arr, i, j):
				result += 1
print(result)


N = int(input())
A = list()
if N < 3:
	print(0)
	exit()
for i in range(N):
	IN = list(input())
	A.append(IN)
Count = 0
for i in range(1, N - 1):
	for j in range(1, N - 1):
		if A[i][j] == 'X' and A[i][j] == A[i - 1][j - 1] and (A[i][j] == A[i - 1][j + 1]) and (A[i + 1][j - 1] == A[i][j]) and (A[i][j] == A[i + 1][j + 1]):
			Count += 1
print(Count)


n = int(input())
a = [list(input()) for _ in range(n)]
cc = 0
for i in range(n):
	for j in range(n):
		if a[i][j] == 'X':
			ch = 0
			if i + 1 < n and n > j + 1:
				if a[i + 1][j + 1] == 'X':
					ch += 1
			if i + 1 < n and j - 1 >= 0:
				if a[i + 1][j - 1] == 'X':
					ch += 1
			if i - 1 >= 0 and n > j + 1:
				if a[i - 1][j + 1] == 'X':
					ch += 1
			if i - 1 >= 0 and j - 1 >= 0:
				if a[i - 1][j - 1] == 'X':
					ch += 1
			if ch == 4:
				cc += 1
print(cc)


n = int(input())
a = []
for i in range(n):
	a.append(input())
e = 0
t1 = [1, -1]
t2 = t1
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if a[i][j] == 'X':
			f = 0
			for x in t1:
				for y in t2:
					try:
						if a[i + x][j + y] != 'X':
							f = 1
							break
					except:
						continue
				if f == 1:
					break
			if f == 0:
				e += 1
print(e)


m = []
count = 0
n = int(input())
for z in range(n):
	a = str(input())
	m.append(a)
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if m[i][j] == 'X' and m[i - 1][j - 1] == 'X' and (m[i - 1][j + 1] == 'X') and (m[i + 1][j - 1] == 'X') and (m[i + 1][j + 1] == 'X'):
			count = count + 1
print(count)


T = int(input())
li = [''] * T
count = 0
for i in range(T):
	li[i] = input()
if T <= 2:
	print(0)
else:
	for i in range(1, T - 1):
		for j in range(1, T - 1):
			if li[i][j] == 'X' and li[i - 1][j - 1] == 'X' and (li[i - 1][j + 1] == 'X') and (li[i + 1][j - 1] == 'X') and (li[i + 1][j + 1] == 'X'):
				count += 1
	print(count)


n = int(input())
list1 = []
for i in range(n):
	s = input()
	list1.append(s)
if n < 3:
	print('0')
else:
	count = 0
	for i in range(1, n - 1):
		for j in range(1, n - 1):
			if list1[i][j] == 'X':
				if list1[i - 1][j - 1] == 'X' and list1[i - 1][j + 1] == 'X' and (list1[i + 1][j - 1] == 'X') and (list1[i + 1][j + 1] == 'X'):
					count += 1
			else:
				continue
	print(count)


def main():
	n = int(input())
	mat = [list(input()) for i in range(n)]
	cnt = 0
	for i in range(n):
		for j in range(n):
			try:
				if mat[i][j] == mat[i][j + 2] == mat[i + 1][j + 1] == mat[i + 2][j] == mat[i + 2][j + 2] == 'X':
					cnt += 1
			except IndexError:
				break
	print(cnt)
main()


n = int(input())
L = []
count = 0
for i in range(n):
	l = list(input())
	L.append(l)
m = len(l)
for i in range(1, n - 1):
	for j in range(1, m - 1):
		if L[i][j] == L[i + 1][j - 1] == L[i - 1][j + 1] == L[i - 1][j - 1] == L[i + 1][j + 1] == 'X':
			count += 1
print(count)


n = int(input())
a = []
cnt = 0
for i in range(n):
	a.append(input())
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if a[i][j] == 'X' and a[i + 1][j - 1] == 'X' and (a[i + 1][j + 1] == 'X') and (a[i - 1][j + 1] == 'X') and (a[i - 1][j - 1] == 'X'):
			cnt += 1
print(cnt)


n = int(input())
t = []
for k in range(n):
	a = list(input())
	t.append(a)
if len(t) < 3:
	print(0)
else:
	p = 0
	for i in range(1, n - 1):
		for j in range(1, n - 1):
			if t[i][j] == 'X':
				if t[i - 1][j - 1] == 'X' and t[i - 1][j + 1] == 'X' and (t[i + 1][j + 1] == 'X') and (t[i + 1][j - 1] == 'X'):
					p += 1
	print(p)


TN = 1

def solution():
	n = int(input())
	m = []
	for i in range(n):
		m.append(list(input()))
	ans = 0
	for i in range(n):
		for j in range(n):
			if i > 0 and j > 0 and (i < n - 1) and (j < n - 1) and (m[i][j] == 'X') and (m[i - 1][j - 1] == 'X') and (m[i - 1][j + 1] == 'X') and (m[i + 1][j - 1] == 'X') and (m[i + 1][j + 1] == 'X'):
				ans += 1
	print(ans)
while TN != 0:
	solution()
	TN -= 1


n = int(input())
a = [input() for i in range(n)]
print(sum((a[i][ii] == 'X' and a[i][ii + 2] == 'X' and (a[i + 1][ii + 1] == 'X') and (a[i + 2][ii] == 'X') and (a[i + 2][ii + 2] == 'X') for i in range(n - 2) for ii in range(n - 2))))


n = int(input())
matrix = []
cnt = 0
for _ in range(n):
	matrix.append(input())
if n < 3:
	print(0)
else:
	for i in range(1, n - 1):
		for j in range(1, n - 1):
			if matrix[i][j] == 'X' and matrix[i - 1][j - 1] == 'X' and (matrix[i + 1][j - 1] == 'X') and (matrix[i - 1][j + 1] == 'X') and (matrix[i + 1][j + 1] == 'X'):
				cnt += 1
	print(cnt)


import os
import sys
from io import BytesIO, IOBase
import math
from decimal import Decimal
from decimal import *
from collections import defaultdict, deque
import heapq
from decimal import Decimal
getcontext().prec = 25
abcd = 'abcdefghijklmnopqrstuvwxyz'
ABCD = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
MOD = 1000000007
BUFSIZE = 8192
from bisect import bisect_left, bisect_right

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
n = int(input())
l = []
for i in range(n):
	l.append(input())
ans = 0
if n < 3:
	print(ans)
else:
	for i in range(1, n - 1):
		for j in range(1, n - 1):
			if l[i][j] == l[i - 1][j - 1] == l[i - 1][j + 1] == l[i + 1][j - 1] == l[i + 1][j + 1] == 'X':
				ans += 1
	print(ans)


t = int(input())
M = []
for i in range(t):
	x = input()
	M.append(x)
count = 0
for i in range(1, t - 1):
	for j in range(1, t - 1):
		if M[i][j] == M[i - 1][j - 1] and M[i][j] == M[i - 1][j + 1] and (M[i][j] == M[i + 1][j - 1]) and (M[i][j] == M[i + 1][j + 1]) and (M[i][j] == 'X'):
			count += 1
print(count)


n = int(input())
a = []
for i in range(n):
	a.append(input())
ans = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if a[i][j] + a[i - 1][j - 1] + a[i - 1][j + 1] + a[i + 1][j - 1] + a[i + 1][j + 1] == 'XXXXX':
			ans += 1
print(ans)


n = int(input())
M = [[*map(str, input())] for _ in range(n)]
ans = 0
for i in range(n):
	for j in range(n):
		if 0 < i < n - 1 and 0 < j < n - 1:
			if M[i][j] == M[i - 1][j - 1] == M[i - 1][j + 1] == M[i + 1][j - 1] == M[i + 1][j + 1] == 'X':
				ans += 1
print(ans)


def find(x, y, matrix):
	if x + 1 >= len(matrix) or x - 1 < 0 or y + 1 >= len(matrix) or (y - 1 < 0):
		return False
	return matrix[x - 1][y - 1] == 'X' and matrix[x - 1][y + 1] == 'X' and (matrix[x + 1][y - 1] == 'X') and (matrix[x + 1][y + 1] == 'X')
num = int(input().strip())
matrix = []
for i in range(num):
	matrix.append([])
	line = input().strip()
	for j in range(num):
		matrix[i].append(line[j])
ans = 0
for i in range(num):
	for j in range(num):
		if matrix[i][j] == 'X':
			if find(i, j, matrix):
				ans += 1
print(ans)


n = int(input())
l = []
for i in range(0, n):
	p = input().rstrip()
	x = list(p)
	l.append(x)
if n <= 2:
	print(0)
else:
	T = 0
	for i in range(1, len(l) - 1):
		for j in range(1, len(l[i]) - 1):
			if l[i][j] == 'X' and l[i - 1][j - 1] == 'X' and (l[i - 1][j + 1] == 'X') and (l[i + 1][j - 1] == 'X') and (l[i + 1][j + 1] == 'X'):
				T += 1
	print(T)


t = int(input())
columns = []
ans = 0
for i in range(t):
	columns.append(input())
for x in range(t):
	for i in range(t):
		if columns[x][i] == 'X' and i != 0 and (i != t - 1) and (x != 0) and (x != t - 1):
			if columns[x + 1][i + 1] == 'X' and columns[x - 1][i - 1] == 'X' and (columns[x + 1][i - 1] == 'X') and (columns[x - 1][i + 1] == 'X'):
				ans += 1
print(ans)


n = int(input())
g = []
for i in range(0, n):
	ln = list(input())
	g.append(ln)
s = 0
for i in range(1, len(g) - 1):
	for j in range(1, len(g) - 1):
		if g[i][j] == 'X' and g[i - 1][j - 1] == 'X' and (g[i - 1][j + 1] == 'X') and (g[i + 1][j - 1] == 'X') and (g[i + 1][j + 1] == 'X'):
			s += 1
print(s)


matrix_size = input()
matrix = []
matrix_size = int(matrix_size)
for i in range(matrix_size):
	matrix.append(input())
ans = 0
for i in range(1, matrix_size - 1):
	for j in range(1, matrix_size - 1):
		if matrix[i][j] == 'X' and matrix[i - 1][j - 1] == 'X' and (matrix[i - 1][j + 1] == 'X') and (matrix[i + 1][j - 1] == 'X') and (matrix[i + 1][j + 1] == 'X'):
			ans += 1
print(ans)


n = int(input())
l = []
k = []
count = 0
t = 0
u = 0
for i in range(1, n + 1):
	v = input()
	v1 = list(v)
	l.append(v1)
if n < 3:
	print('0')
else:
	for t in range(1, n - 1):
		for u in range(1, n - 1):
			no = 'X'
			if l[t - 1][u + 1] == no and l[t + 1][u + 1] == no and (l[t + 1][u - 1] == no) and (l[t - 1][u - 1] == no) and (l[t][u] == no):
				count = count + 1
	print(count)


n = int(input())
a = []
for i in range(n):
	a.append([])
	for j in input():
		if j == 'X':
			a[-1].append(1)
		else:
			a[-1].append(0)
ans = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if a[i][j] == 1 == a[i - 1][j - 1] == a[i - 1][j + 1] == a[i + 1][j - 1] == a[i + 1][j + 1]:
			ans += 1
print(ans)


n = int(input())
m = [input() for i in range(n)]
res = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if m[i][j] == m[i - 1][j - 1] == m[i - 1][j + 1] == m[i + 1][j - 1] == m[i + 1][j + 1] == 'X':
			res += 1
print(res)


n = int(input())
m = ['.' + input().strip() + '.' for _ in range(n)]
m = ['.' * (n + 2)] + m + ['.' * (n + 2)]
r = 0
for i in range(1, n + 1):
	for j in range(1, n + 1):
		if m[i][j] == '.':
			continue
		if m[i - 1][j - 1] == '.':
			continue
		if m[i - 1][j + 1] == '.':
			continue
		if m[i + 1][j - 1] == '.':
			continue
		if m[i + 1][j + 1] == '.':
			continue
		r += 1
print(r)


n = int(input())
b = []
count = 0
for i in range(n):
	s = input()
	b.append(s)
for i in range(n - 2):
	for j in range(n - 2):
		if b[i][j] == 'X' == b[i][j + 2] == b[i + 1][j + 1] == 'X' == b[i + 2][j] == b[i + 2][j + 2] == 'X':
			count += 1
print(count)


n = int(input())
data = [input() for _ in range(n)]
res = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if data[i][j] == 'X' and data[i - 1][j - 1] == 'X' and (data[i - 1][j + 1] == 'X') and (data[i + 1][j - 1] == 'X') and (data[i + 1][j + 1] == 'X'):
			res += 1
print(res)


n = int(input())
M = []
for i in range(n):
	M.append(list(input()))
res = 0
for i in range(1, len(M) - 1):
	for j in range(1, len(M[i]) - 1):
		if M[i][j] == M[i - 1][j - 1] == M[i + 1][j + 1] == M[i - 1][j + 1] == M[i + 1][j - 1] == 'X':
			res += 1
print(res)


n = int(input())
mat = []
for i in range(n):
	str_ = input()
	mat.append(str_)
sol = 0
for i in range(n):
	for j in range(n):
		try:
			if mat[i][j] == 'X' and mat[i + 1][j + 1] == 'X' and (mat[i + 1][j - 1] == 'X') and (mat[i - 1][j + 1] == 'X') and (mat[i - 1][j - 1] == 'X') and (i - 1 >= 0) and (j - 1 >= 0):
				sol += 1
		except:
			pass
print(sol)


N = int(input())
M = [0 for i in range(N)]
for i in range(N):
	M[i] = list(input())
cross = 0
for i in range(1, N - 1):
	for j in range(1, N - 1):
		if M[i][j] == M[i - 1][j - 1] == M[i - 1][j + 1] == M[i + 1][j - 1] == M[i + 1][j + 1] == 'X':
			cross += 1
print(cross)


NumOfCrosses = 0
n = int(input())
M = []
for i in range(n):
	M.append(list(input()))
else:
	for i in range(1, n - 1):
		for j in range(1, n - 1):
			if M[i][j] == 'X' and M[i - 1][j - 1] == 'X' and (M[i - 1][j + 1] == 'X') and (M[i + 1][j - 1] == 'X') and (M[i + 1][j + 1] == 'X'):
				NumOfCrosses += 1
	print(NumOfCrosses)


f = lambda : map(int, input().split())
n = int(input())
a = n
m = []
c = 0
while n:
	s = list(input())
	m.append(s)
	n -= 1
for i in range(1, a - 1):
	for j in range(1, a - 1):
		if m[i][j] == m[i - 1][j - 1] == m[i - 1][j + 1] == m[i + 1][j - 1] == m[i + 1][j + 1] == 'X':
			c += 1
print(c)


z = input
lx = []
n = int(z())
for _ in range(n):
	l = list(z())
	lx.append(l)
c = 0
l = lx[:]
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if l[i][j] == l[i - 1][j - 1] == l[i - 1][j + 1] == l[i + 1][j - 1] == l[i + 1][j + 1] == 'X':
			c += 1
print(c)


def solve(n, m):
	c = 0
	for i in range(1, n - 1):
		for j in range(1, n - 1):
			if m[i][j] == m[i - 1][j - 1] == m[i - 1][j + 1] == m[i + 1][j - 1] == m[i + 1][j + 1] == 'X':
				c += 1
	return c

def main():
	n = int(input())
	m = [input() for i in range(n)]
	print(solve(n, m))
main()


import sys
from collections import defaultdict as dd
from itertools import permutations as pp
from itertools import combinations as cc
from collections import Counter as ccd
from random import randint as rd
from bisect import bisect_left as bl
import heapq
mod = 10 ** 9 + 7

def ri(flag=0):
	if flag == 0:
		return [int(i) for i in sys.stdin.readline().split()]
	else:
		return int(sys.stdin.readline())
n = int(input())
mat = []
for i in range(n):
	mat.append(input())
mat
c = 0
for i in range(n):
	for j in range(n):
		if i + 1 < n and i - 1 >= 0 and (j + 1 < n) and (j - 1 >= 0):
			if mat[i][j] == 'X' and mat[i - 1][j - 1] == 'X' and (mat[i + 1][j + 1] == 'X') and (mat[i - 1][j + 1] == 'X') and (mat[i + 1][j - 1] == 'X'):
				c += 1
print(c)


n = int(input())
m = [[] for _ in range(n)]
for i in range(n):
	m[i] = list(input().strip())
c = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if m[i][j] == m[i - 1][j - 1] and m[i][j] == m[i - 1][j + 1] and (m[i][j] == m[i + 1][j - 1]) and (m[i][j] == m[i + 1][j + 1]) and (m[i][j] == 'X'):
			c += 1
print(c)


n = int(input())
a = [input() for i in range(n)]
r = 0
for i in range(n - 2):
	for j in range(n - 2):
		if a[i][j] == a[i][j + 2] == a[i + 1][j + 1] == a[i + 2][j] == a[i + 2][j + 2] == 'X':
			r += 1
print(r)


a = int(input())
l = []
ans = 0
for i in range(a):
	b = input()
	l.append(b)
if a < 3:
	print(0)
	exit()
for i in range(1, a - 1):
	for j in range(1, a - 1):
		if l[i][j] == l[i - 1][j - 1] and l[i][j] == l[i + 1][j - 1] and (l[i][j] == l[i - 1][j + 1]) and (l[i][j] == l[i + 1][j + 1]) and (l[i][j] != '.'):
			ans += 1
print(ans)


from itertools import product
n = int(input())
a = []
ans = 0
for _ in range(n):
	a.append(input())
for (i, j) in product(range(n - 2), repeat=2):
	if a[i][j] == a[i][j + 2] == a[i + 1][j + 1] == a[i + 2][j] == a[i + 2][j + 2] == 'X':
		ans += 1
print(ans)


n = int(input())
a = [input() for _ in range(n)]
r = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if set([a[i][j], a[i - 1][j - 1], a[i - 1][j + 1], a[i + 1][j - 1], a[i + 1][j + 1]]) == {'X'}:
			r += 1
print(r)


q = int(input())
a = list()
b = list()
w = int(0)
for i in range(q):
	s = input()
	for k in range(q):
		b.append(s[k])
	a.append(b[:])
	b.clear()
if q < 3:
	print(0)
	exit()
for i in range(1, q - 1, 1):
	for j in range(1, q - 1, 1):
		if a[i][j] == a[i - 1][j - 1] == a[i - 1][j + 1] == a[i + 1][j - 1] == a[i + 1][j + 1] == 'X':
			w += 1
print(w)


n = int(input())
a = []
for i in range(0, n):
	a.append(list(input()))
cnt = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		c = a[i][j] + a[i - 1][j - 1] + a[i - 1][j + 1] + a[i + 1][j - 1] + a[i + 1][j + 1]
		if c == 'XXXXX':
			cnt += 1
print(cnt)


n = int(input())
d = []
if n < 3:
	print(0)
else:
	for i in range(n):
		s = input()
		d.append(s)
	c = 0
	for i in range(1, n - 1):
		for l in range(1, n - 1):
			if d[i][l] == d[i - 1][l - 1] and d[i - 1][l + 1] == d[i - 1][l - 1] and (d[i - 1][l + 1] == d[i + 1][l - 1]) and (d[i + 1][l - 1] == d[i + 1][l + 1]) and (d[i + 1][l + 1] == 'X'):
				c = c + 1
	print(c)


n = int(input())
M = []
s = 0
for i in range(n):
	k = list(input())
	M.append(k)
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if M[i][j] == M[i - 1][j - 1] == M[i - 1][j + 1] == M[i + 1][j - 1] == M[i + 1][j + 1] == 'X':
			s += 1
print(s)


n = int(input())
cnt = 0
M = [input() for i in range(n)]
for i in range(1, n - 1):
	for j in range(1, n - 1):
		s = set([M[i][j], M[i - 1][j - 1], M[i - 1][j + 1], M[i + 1][j - 1], M[i + 1][j + 1]])
		if s == {'X'}:
			cnt += 1
print(cnt)


n = int(input())
a = []
for i in range(n):
	a.append([])
	str_in = str(input())
	for j in range(n):
		a[i].append(str_in[j])
if n <= 2:
	print(0)
else:
	ans = 0
	for i in range(n - 2):
		for j in range(n - 2):
			if a[i][j] == 'X' and a[i + 1][j + 1] == 'X' and (a[i + 2][j + 2] == 'X') and (a[i + 2][j] == 'X') and (a[i][j + 2] == 'X'):
				ans += 1
	print(ans)


n = int(input())
l = []
for i in range(n):
	str = input()
	l.append(str[:n])
ct = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if l[i][j] == 'X' and l[i - 1][j - 1] == 'X' and (l[i - 1][j + 1] == 'X') and (l[i + 1][j + 1] == 'X') and (l[i + 1][j - 1] == 'X'):
			ct += 1
print(ct)


n = int(input())
l = []
sum = 0
for i in range(n):
	s = input()
	temp = []
	for j in range(n):
		temp.append(s[j])
	l.append(temp)
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if l[i][j] == 'X' and l[i][j] == l[i + 1][j + 1] and (l[i][j] == l[i - 1][j - 1]) and (l[i][j] == l[i + 1][j - 1]) and (l[i][j] == l[i - 1][j + 1]):
			sum += 1
print(sum)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def main():
	n = I()
	a = [S() for _ in range(n)]
	r = 0
	t = [(-1, -1), (-1, +1), (+1, -1), (+1, +1), (0, 0)]
	for i in range(1, n - 1):
		for j in range(1, n - 1):
			if all((a[i + k][j + l] == 'X' for (k, l) in t)):
				r += 1
	return r
print(main())


n = int(input())
matrix = []
for k in range(n):
	matrix.append(list(input()))
counts = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if matrix[i][j] == 'X':
			if matrix[i + 1][j - 1] == 'X':
				if matrix[i + 1][j + 1] == 'X':
					if matrix[i - 1][j - 1] == 'X':
						if matrix[i - 1][j + 1] == 'X':
							counts += 1
print(counts)


n = int(input())
a = []
for i in range(n):
	d = input()
	a.append(d)
count = 0
for i in range(n):
	for j in range(n):
		count1 = 0
		if a[i][j] == 'X':
			if (i - 1 >= 0 and j + 1 < n) and a[i - 1][j + 1] == 'X':
				count1 += 1
			if (i - 1 >= 0 and j - 1 >= 0) and a[i - 1][j - 1] == 'X':
				count1 += 1
			if (i + 1 < n and j + 1 < n) and a[i + 1][j + 1] == 'X':
				count1 += 1
			if (i + 1 < n and j - 1 >= 0) and a[i + 1][j - 1] == 'X':
				count1 += 1
			if count1 == 4:
				count += 1
print(count)


rows = int(input())
array = [[] for i in range(rows)]
for i in range(rows):
	array[i] = [s for s in input()]
counter = 0
for i in range(rows):
	for j in range(rows):
		if (i >= 1 and i <= rows - 2) and (j >= 1 and j <= rows - 2):
			if array[i][j] == array[i - 1][j - 1] and array[i - 1][j - 1] == array[i - 1][j + 1] and (array[i - 1][j + 1] == array[i + 1][j - 1]) and (array[i + 1][j - 1] == array[i + 1][j + 1]) and (array[i][j] == 'X'):
				counter += 1
print(counter)


n = int(input())
matrix = [list(input()) for _ in range(n)]
answer = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if matrix[i][j] == 'X' and matrix[i - 1][j - 1] == 'X' and (matrix[i + 1][j - 1] == 'X') and (matrix[i - 1][j + 1] == 'X') and (matrix[i + 1][j + 1] == 'X'):
			answer += 1
print(answer)


from sys import stdin
n = int(stdin.readline().strip())
mat = [[0 for i in range(n)] for j in range(n)]
for i in range(n):
	mat[i] = list(stdin.readline().strip())
count = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if mat[i][j] == 'X':
			if mat[i - 1][j - 1] == 'X' and mat[i - 1][j + 1] == 'X' and (mat[i + 1][j - 1] == 'X') and (mat[i + 1][j + 1] == 'X'):
				count += 1
print(count)


import os
import sys
from io import BytesIO, IOBase
from collections import defaultdict, deque, Counter, OrderedDict
import threading
from heapq import *
(kx, ky) = ([1, 1, -1, -1], [1, -1, 1, -1])

def main():

	def B(x, y):
		for i in range(4):
			(nx, ny) = (x + kx[i], y + ky[i])
			if D[nx][ny] == '.':
				return 0
		return 1
	n = int(input())
	D = [input() for _ in range(n)]
	ans = 0
	for i in range(1, n - 1):
		for j in range(1, n - 1):
			if D[i][j] == 'X':
				ans += B(i, j)
	print(ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


n = int(input())
a = [list((q == 'X' for q in line)) for line in (input() for _ in range(n))]
c = sum((all((a[i + q][j + w] for q in (-1, 1) for w in (-1, 1))) and a[i][j] for i in range(1, n - 1) for j in range(1, n - 1)))
print(c)


m = int(input())
arr = []
for i in range(m):
	arr += [input()]
x_count = 0
for i in range(m):
	for j in range(len(arr[i])):
		if i - 1 >= 0 and i + 1 < m and (j - 1 >= 0) and (j + 1 < m) and (arr[i][j] == arr[i - 1][j - 1] == arr[i + 1][j + 1] == arr[i - 1][j + 1] == arr[i + 1][j - 1] == 'X'):
			x_count += 1
print(x_count)


n = int(input())
a = []
for i in range(n):
	a.append(list(input()))
s = 0
for i in range(1, n - 1):
	for l in range(1, n - 1):
		if a[i][l] == 'X' and a[i - 1][l + 1] == 'X' and (a[i - 1][l - 1] == 'X') and (a[i + 1][l - 1] == 'X') and (a[i + 1][l + 1] == 'X'):
			s += 1
print(s)


n = int(input())
if n < 3:
	print('0')
else:
	m = tuple((input().lower() for _ in range(n)))
	res = 0
	for i in range(1, n - 1):
		for j in range(1, n - 1):
			if m[i][j] == m[i - 1][j - 1] == m[i - 1][j + 1] == m[i + 1][j - 1] == m[i + 1][j + 1] == 'x':
				res += 1
	print(res)


matrix = []
counter = 0
n = int(input())
if n >= 3:
	for i in range(n):
		matrix.append(input())
	for x in range(n):
		for y in range(n):
			try:
				if matrix[x][y] == matrix[x + 1][y + 1] == matrix[x + 2][y + 2] == matrix[x][y + 2] == matrix[x + 2][y] == 'X':
					counter += 1
			except:
				break
else:
	for i in range(n):
		matrix.append(input())
	counter = 0
print(counter)


n = int(input())
mainarr = [[i for i in input().split()] for j in range(n)]
res = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if mainarr[i][0][j] == mainarr[i + 1][0][j + 1] == mainarr[i - 1][0][j - 1] == mainarr[i + 1][0][j - 1] == mainarr[i - 1][0][j + 1] == 'X':
			res += 1
print(res)


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_intList_from_str = lambda : list(map(int, list(sys.stdin.readline().strip())))
get_charList_from_str = lambda : list(sys.stdin.readline().strip())
get_int = lambda : int(sys.stdin.readline().strip())
pt = lambda x: sys.stdout.write(str(x))
n = get_int()
if n < 3:
	l = [get_charList_from_str() for x in range(n)]
	print(0)
else:
	matrix = [get_charList_from_str() for x in range(n)]
	Allow = True
	first = second = 0
	for i in range(n):
		if 'X' in matrix[i]:
			if Allow:
				first = i
				Allow = False
			second = i
	count_x = 0
	for i in range(first + 1, second):
		l = matrix[i]
		for j in range(1, n - 1):
			if l[j] == 'X':
				if matrix[i - 1][j - 1] == 'X' and matrix[i - 1][j + 1] == 'X' and (matrix[i + 1][j - 1] == 'X') and (matrix[i + 1][j + 1] == 'X'):
					count_x += 1
	print(count_x)


from __future__ import division, print_function
import cmath
import itertools
import math
import operator as op
import sys
from atexit import register
from bisect import bisect_left, bisect_right
if sys.version_info[0] < 3:
	from io import BytesIO as stream
else:
	from io import StringIO as stream
if sys.version_info[0] < 3:

	class dict(dict):

		def items(self):
			return dict.iteritems(self)

		def keys(self):
			return dict.iterkeys(self)

		def values(self):
			return dict.itervalues(self)
	input = raw_input
	range = xrange
	filter = itertools.ifilter
	map = itertools.imap
	zip = itertools.izip

def sync_with_stdio(sync=True):
	global input, flush
	if sync:
		flush = sys.stdout.flush
	else:
		sys.stdin = stream(sys.stdin.read())
		input = lambda : sys.stdin.readline().rstrip('\r\n')
		sys.stdout = stream()
		register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def main():
	n = int(input())
	m = [input() for _ in range(n)]
	c = 0
	for i in range(1, n - 1):
		for j in range(1, n - 1):
			if m[i][j] == m[i - 1][j - 1] == m[i - 1][j + 1] == m[i + 1][j - 1] == m[i + 1][j + 1] == 'X':
				c += 1
	print(c)
sync_with_stdio(False)
main()


def main():
	n = int(input())
	matrix = [input() for _ in range(n)]
	count = 0
	for i in range(1, n - 1):
		for j in range(1, n - 1):
			count += 1 if matrix[i][j] == 'X' and matrix[i - 1][j - 1] == 'X' and (matrix[i - 1][j + 1] == 'X') and (matrix[i + 1][j - 1] == 'X') and (matrix[i + 1][j + 1] == 'X') else 0
	print(count)
main()


n = int(input())
a = []
for i in range(n):
	a.append(input())
if n <= 2:
	print(0)
else:
	k = 0
	for i in range(1, n - 1):
		for j in range(1, n - 1):
			if a[i][j] == a[i - 1][j - 1] == a[i - 1][j + 1] == a[i + 1][j - 1] == a[i + 1][j + 1] == 'X':
				k += 1
	print(k)


def A():
	n = int(input())
	m = [input() for _ in range(n)]
	cnt = 0
	for i in range(1, n - 1):
		for j in range(1, n - 1):
			if m[i][j] == m[i - 1][j - 1] == m[i + 1][j + 1] == m[i - 1][j + 1] == m[i + 1][j - 1] == 'X':
				cnt += 1
	print(cnt)
A()


from math import *
from cmath import *
from itertools import *
from decimal import *
from fractions import *
from sys import *
from types import CodeType, new_class
n = int(input())
if n <= 2:
	print(0)
	exit()
a = []
for x in range(n):
	a.append(input())
ans = 0
for x in range(1, n - 1):
	for y in range(1, n - 1):
		if a[x][y] == 'X' and a[x - 1][y - 1] == 'X' and (a[x + 1][y - 1] == 'X') and (a[x - 1][y + 1] == 'X') and (a[x + 1][y + 1] == 'X'):
			ans += 1
print(ans)


n = int(input())
m = []
for i in range(n):
	s = input()
	m += [s]
cnt = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if m[i][j] == m[i - 1][j - 1] == m[i - 1][j + 1] == m[i + 1][j + 1] == m[i + 1][j - 1] == 'X':
			cnt += 1
print(cnt)


n = int(input())
a = [input() for _ in [0] * n]
ans = 0
for y in range(1, n - 1):
	for x in range(1, n - 1):
		if a[y][x] == a[y - 1][x - 1] == a[y - 1][x + 1] == a[y + 1][x - 1] == a[y + 1][x + 1] == 'X':
			ans += 1
print(ans)


n = int(input())
y = []
ans = 0
if n < 3:
	print(0)
	exit()
for i in range(n):
	x = list(input())
	y.append(x)
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if (y[i][j] == 'X' and y[i - 1][j + 1] == 'X') and (y[i + 1][j - 1] == 'X' and y[i + 1][j + 1] == 'X') and (y[i - 1][j - 1] == 'X'):
			ans += 1
print(ans)


n = int(input())
l = []
for i in range(n):
	l.append(list(input()))
k = 0
if n < 3:
	print(0)
elif n == 3:
	if l[0][0] == l[0][2] == l[1][1] == l[2][0] == l[2][2] == 'X':
		print(1)
	else:
		print(0)
else:
	for i in range(1, n - 1):
		for j in range(1, n - 1):
			if l[i][j] == l[i - 1][j - 1] == l[i + 1][j + 1] == l[i + 1][j - 1] == l[i - 1][j + 1] == 'X':
				k += 1
	print(k)


import math
import bisect as bis
n = int(input())
a = []
for i in range(n):
	a.append(input())
dr = [-1, -1, 1, 1]
dc = [-1, 1, -1, 1]
cnt = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if a[i][j] == 'X':
			decide = 1
			for k in range(4):
				if a[i + dr[k]][j + dc[k]] != 'X':
					decide = 0
			if decide == 1:
				cnt += 1
print(cnt)


n = int(input())
l = []
co = 0
for i in range(n):
	e = input()
	l.append(e)
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if l[i][j] == 'X':
			if l[i + 1][j + 1] == l[i - 1][j - 1] == l[i - 1][j + 1] == l[i + 1][j - 1] == l[i + 1][j + 1] == 'X':
				co += 1
print(co)


n = int(input())
s = [input() for i in range(n)]
ans = 0
if n >= 3:
	for i in range(1, n - 1):
		for j in range(1, n - 1):
			if s[i][j] == 'X':
				if s[i - 1][j - 1] == 'X' and s[i - 1][j + 1] == 'X' and (s[i + 1][j - 1] == 'X') and (s[i + 1][j + 1] == 'X'):
					ans += 1
print(ans)


n = int(input())
r = range(n)
M = [input() for i in r]
print(sum(((lambda x, y: 0 < min(x, y) <= max(x, y) < n - 1 and len(set(['X', M[x][y], M[x - 1][y - 1], M[x - 1][y + 1], M[x + 1][y - 1], M[x + 1][y + 1]])) == 1)(x, y) for x in r for y in r)))


import sys
import os
import io
from sys import stdin, stdout
n = stdin.readline()
n = int(n)
l = []
ans = 0
for _ in range(n):
	f = stdin.readline()
	l.append(f)
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if l[i][j] == 'X' and l[i - 1][j - 1] == 'X' and (l[i - 1][j + 1] == 'X') and (l[i + 1][j - 1] == 'X') and (l[i + 1][j + 1] == 'X'):
			ans += 1
print(ans)


N = 150
n = int(input())
a = []
for i in range(n):
	a.append(input())
ans = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if a[i][j] == 'X' and a[i - 1][j - 1] == 'X' and (a[i - 1][j + 1] == 'X') and (a[i + 1][j - 1] == 'X') and (a[i + 1][j + 1] == 'X'):
			ans += 1
print(ans)


m = int(input())
matrix = []
for i in range(m):
	st = list(input())
	matrix.append(st)

def sourch(mat, m):
	temp = 0
	for i in range(m - 2):
		for j in range(m - 2):
			if mat[i][j] == mat[i][j + 2] == mat[i + 2][j] == mat[i + 1][j + 1] == mat[i + 2][j + 2] == 'X':
				temp += 1
			else:
				continue
	return temp
print(sourch(matrix, m))


import sys
n = int(input())
l = []
for i in range(n):
	s = input()
	l.append(s)
if n < 3:
	print(0)
	sys.exit(0)
co = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if l[i][j] == 'X':
			if l[i + 1][j - 1] == 'X' and l[i + 1][j + 1] == 'X' and (l[i - 1][j + 1] == 'X') and (l[i - 1][j - 1] == 'X'):
				co += 1
print(co)


n = int(input())
matrix = []
for i in range(n):
	line = list(input())
	matrix.append(line)

def is_valid(i, j):
	global matrix
	if matrix[i][j] == 'X' and matrix[i][j] == matrix[i - 1][j - 1] and (matrix[i][j] == matrix[i + 1][j + 1]) and (matrix[i][j] == matrix[i - 1][j + 1]) and (matrix[i][j] == matrix[i + 1][j - 1]):
		return True
	return False

def main():
	global n, matrix
	if n < 3:
		print(0)
		return
	result = 0
	for i in range(1, n - 1):
		for j in range(1, n - 1):
			if is_valid(i, j):
				result += 1
	print(result)
main()


n = int(input())
s = []
r = 0
for i in range(n):
	s.append(input())
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if s[i][j] == s[i - 1][j - 1] == s[i - 1][j + 1] == s[i + 1][j - 1] == s[i + 1][j + 1] == 'X':
			r += 1
print(r)


z = []
a = int(input())
s = 0
for _ in ' ' * a:
	z += [input()]
for i in range(1, a - 1):
	for j in range(1, a - 1):
		if z[i - 1][j - 1] == z[i - 1][j + 1] == z[i + 1][j + 1] == z[i + 1][j - 1] == 'X' == z[i][j]:
			s += 1
print(s)


num = int(input())
counter = 0
lst = []
for i in range(num):
	lst.append(input())
for i in range(num):
	if i - 1 >= 0 and i - 1 < num and (i + 1 >= 0) and (i + 1 < num):
		for j in range(num):
			if j - 1 >= 0 and j - 1 < num and (j + 1 >= 0) and (j + 1 < num):
				if lst[i][j] == lst[i - 1][j - 1] == lst[i - 1][j + 1] == lst[i + 1][j - 1] == lst[i + 1][j + 1] == 'X':
					counter += 1
print(counter)


n = int(input())
a = []
for i in range(n):
	a.append([])
	b = input()
	for elem in b:
		a[i].append(elem)
ans = 0
for i in range(n):
	for j in range(n):
		if a[i][j] == 'X':
			if i - 1 > -1 and j - 1 > -1 and (a[i - 1][j - 1] == 'X'):
				if j + 1 < n and a[i - 1][j + 1] == 'X':
					if i + 1 < n and a[i + 1][j - 1] == 'X':
						if a[i + 1][j + 1] == 'X':
							ans += 1
print(ans)


import copy
import fractions
import itertools
import numbers
import string
import sys

def powmod(x, p, m):
	if p <= 0:
		return 1
	if p <= 1:
		return x % m
	return powmod(x * x % m, p // 2, m) * (x % m) ** (p % 2) % m

def to_basex(num, x):
	while num > 0:
		yield (num % x)
		num //= x

def from_basex(it, x):
	ret = 0
	p = 1
	for d in it:
		ret += d * p
		p *= x
	return ret

def core():
	n = int(input())
	M = []
	for _ in range(n):
		M.append(input())
	ans = 0
	for i in range(1, n - 1):
		for j in range(1, n - 1):
			if {M[i - 1][j - 1], M[i - 1][j + 1], M[i + 1][j - 1], M[i + 1][j + 1], M[i][j]} == {'X'}:
				ans += 1
	print(ans)
core()


n = int(input())
M = []
x = 0
for i in range(n):
	L = [s for s in input()]
	M.append(L)
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if M[i][j] == M[i - 1][j - 1] == M[i - 1][j + 1] == M[i + 1][j - 1] == M[i + 1][j + 1] == 'X':
			x += 1
print(x)


n = int(input())
l = [input() for _ in range(n)]
c = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if set([l[i][j], l[i + 1][j - 1], l[i - 1][j + 1], l[i + 1][j + 1], l[i - 1][j - 1]]) == {'X'}:
			c += 1
print(c)


n = int(input())
A = [input() for i in range(n)]
print(sum((1 for i in range(1, n - 1) for j in range(1, n - 1) if A[i - 1][j - 1] == A[i - 1][j + 1] == A[i][j] == A[i + 1][j - 1] == A[i + 1][j + 1] == 'X')))


def ans(arr, n):
	cnt = 0
	temp = ['.' * (n + 2)]
	for i in range(n):
		temp += ['.' + ''.join(arr[i]) + '.']
	temp.append('.' * (n + 2))
	for i in range(1, n + 2):
		for j in range(1, n + 2):
			if temp[i][j] == 'X':
				if temp[i - 1][j - 1] == temp[i - 1][j + 1] == temp[i + 1][j - 1] == temp[i + 1][j + 1] == 'X':
					cnt += 1
	return cnt
t = int(input())
temp = []
for _ in range(t):
	temp.append([input()])
print(ans(temp, t))


import itertools
import sys
N = int(input())
M = [input() for _ in range(N)]
if N < 3:
	print(0)
	sys.exit()
ans = 0
for i in range(1, N - 1):
	for j in range(1, N - 1):
		if M[i][j] == '.':
			continue
		for (k, l) in itertools.product([1, -1], repeat=2):
			if M[i + k][j + l] == '.':
				break
		else:
			ans += 1
print(ans)


import sys

def get_array():
	return list(map(int, sys.stdin.readline().split()))

def get_ints():
	return map(int, sys.stdin.readline().split())

def input():
	return sys.stdin.readline().strip('\n')
n = int(input())
l = []
for i in range(n):
	l.append(input())
c = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if l[i - 1][j - 1] == l[i - 1][j + 1] == l[i][j] == l[i + 1][j - 1] == l[i + 1][j + 1] == 'X':
			c += 1
print(c)


n = int(input())
matrix = []
for i in range(n):
	temp_list = []
	temp_str = input()
	matrix.append(temp_str)
if n < 3:
	print(0)
	exit(0)
c = 0
for i in range(n):
	if i > 0 and i < n - 1:
		for j in range(n):
			if j > 0 and j < n - 1:
				if matrix[i - 1][j - 1] == matrix[i + 1][j - 1] == 'X' and matrix[i - 1][j + 1] == matrix[i + 1][j + 1] == matrix[i][j] == 'X':
					c += 1
print(c)


aa = []
res = 0
n = int(input())
for _ in range(n):
	aa.append(list(map({'X': 1, '.': 0}.get, input())))

def check(i, j):
	sm = aa[i][j]
	for di in [-1, 1]:
		for dj in [-1, 1]:
			sm += aa[i + di][j + dj]
	return sm == 5
for i in range(1, n - 1):
	for j in range(1, n - 1):
		res += check(i, j)
print(res)


import sys
arr = []
n = int(input())
for i in range(n):
	line = str(input()).lower()
	temp = []
	for item in line:
		temp.append(item)
	arr.append(temp)
count = 0
if n < 3:
	print(0)
	sys.exit(0)
for i in range(n):
	for j in range(n):
		if i >= 1 and j >= 1 and (j < n - 1) and (i < n - 1):
			if arr[i][j] == arr[i - 1][j - 1] == arr[i - 1][j + 1] == arr[i + 1][j - 1] == arr[i + 1][j + 1] == 'x':
				count += 1
print(count)


n = int(input())
table = []
ans = 0
for y in range(n):
	table.append(list(input()))
for y in range(1, n - 1):
	for x in range(1, n - 1):
		if table[y - 1][x - 1] == 'X' and table[y - 1][x + 1] == 'X' and (table[y + 1][x - 1] == 'X') and (table[y + 1][x + 1] == 'X') and (table[y][x] == 'X'):
			ans += 1
print(ans)


n = int(input())
matrix = []
for i in range(n):
	matrix.append([0] * n)
for row in range(n):
	s = input()
	for j in range(n):
		if s[j] == 'X':
			matrix[row][j] = 1
c = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if matrix[i][j] == 1:
			if matrix[i - 1][j - 1] == 1 and matrix[i - 1][j + 1] == 1 and (matrix[i + 1][j - 1] == 1) and (matrix[i + 1][j + 1] == 1):
				c += 1
print(c)


def testa(M, i, j, n):
	aux = 0
	if i > 0:
		if j > 0:
			if M[i - 1][j - 1] == 'X':
				aux += 1
		if j < n - 1:
			if M[i - 1][j + 1] == 'X':
				aux += 1
	if i < n - 1:
		if j > 0:
			if M[i + 1][j - 1] == 'X':
				aux += 1
		if j < n - 1:
			if M[i + 1][j + 1] == 'X':
				aux += 1
	if aux == 4:
		return 1
	return 0
cont = 0
n = int(input())
M = []
for i in range(n):
	linha = input()
	k = []
	for j in linha:
		k.append(j)
	M.append(k)
for i in range(n):
	for j in range(n):
		if M[i][j] == 'X':
			cont += testa(M, i, j, n)
print(cont)


import math
from collections import Counter
import itertools
n = int(input())
l = []
for i in range(n):
	l += [list(input())]
f = 0
t = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if l[i][j] == 'X' and l[i - 1][j - 1] == 'X' and (l[i + 1][j + 1] == 'X') and (l[i - 1][j + 1] == 'X') and (l[i + 1][j - 1] == 'X'):
			f += 1
		else:
			pass
print(f)


size = int(input())
T = [0] * size
count = 0
for i in range(len(T)):
	T[i] = input()
if size > 2:
	for j in range(size - 2):
		for k in range(size - 2):
			if T[j][k] == 'X' and T[j][k + 2] == 'X':
				if T[j + 1][k + 1] == 'X':
					if T[j + 2][k] == 'X' and T[j + 2][k + 2] == 'X':
						count += 1
print(count)


def cross(m, i, j):
	return m[i][j] == m[i][j + 2] == m[i + 1][j + 1] == m[i + 2][j] == m[i + 2][j + 2] == 'X'
n = int(input())
m = [input() for _ in range(n)]
print([cross(m, i, j) for i in range(n - 2) for j in range(n - 2)].count(True))


n = int(input())
matrix = []
for i in range(n):
	matrix.append(input())
m = len(matrix[0])
ans = 0

def valid_position(x, y):
	return x >= 0 and x < n and (y >= 0) and (y < m)

def is_cross(x, y):
	if valid_position(x - 1, y - 1) and valid_position(x + 1, y + 1) and valid_position(x - 1, y + 1) and valid_position(x + 1, y - 1):
		return matrix[x - 1][y - 1] == 'X' and matrix[x + 1][y + 1] == 'X' and (matrix[x - 1][y + 1] == 'X') and (matrix[x + 1][y - 1] == 'X')
	return False
for i in range(n):
	for j in range(m):
		if matrix[i][j] == 'X' and is_cross(i, j):
			ans += 1
print(ans)


a = int(input())
m = list()
for i in range(a):
	tmp = input()
	m.append(tmp)
count = 0
for i in range(1, a - 1):
	for j in range(1, a - 1):
		if m[i - 1][j - 1] + m[i + 1][j + 1] + m[i - 1][j + 1] + m[i + 1][j - 1] + m[i][j] == 'XXXXX':
			count += 1
print(count)


n = int(input())
a = []
for i in range(n):
	temp = []
	temp = str(input())
	a.append(temp)
c = 0
if n < 3:
	print(0)
else:
	for j in range(1, n - 1):
		for k in range(1, len(a[j]) - 1):
			if a[j][k] == 'X' and a[j - 1][k - 1] == 'X' and (a[j - 1][k + 1] == 'X') and (a[j + 1][k - 1] == 'X') and (a[j + 1][k + 1] == 'X'):
				c = c + 1
	print(c)


n = int(input())
z = []
for _ in range(n):
	z.append(input())
count = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if {z[i][j], z[i - 1][j - 1], z[i - 1][j + 1], z[i + 1][j - 1], z[i + 1][j + 1]} == {'X'}:
			count += 1
print(count)


ii = lambda : int(input())
il = lambda : list(map(int, input().split()))
ilf = lambda : list(map(float, input().split()))
ip = lambda : input()
fi = lambda : float(input())
li = lambda : list(input())
pr = lambda x: print(x)
n = ii()
a = []
if n <= 2:
	print(0)
	exit(0)
for i in range(n):
	a.append(ip())
ans = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if a[i][j] == 'X' == a[i - 1][j - 1] == a[i - 1][j + 1] == a[i + 1][j - 1] == a[i + 1][j + 1] == 'X':
			ans += 1
print(ans)


import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 5)

def li():
	return map(int, stdin.readline().split())

def li_():
	return map(lambda x: int(x) - 1, stdin.readline().split())

def lf():
	return map(float, stdin.readline().split())

def ls():
	return stdin.readline().split()

def ns():
	return stdin.readline().rstrip()

def lc():
	return list(ns())

def ni():
	return int(stdin.readline())

def nf():
	return float(stdin.readline())
n = ni()
grid = [ns() for _ in range(n)]
if n < 3:
	print(0)
else:
	ans = 0
	for r in range(n - 2):
		for c in range(n - 2):
			if grid[r][c] == 'X' and grid[r][c + 2] == 'X' and (grid[r + 1][c + 1] == 'X') and (grid[r + 2][c] == 'X') and (grid[r + 2][c + 2] == 'X'):
				ans += 1
	print(ans)


n = int(input())
c = 0
s = ['0' for i in range(n)]
for i in range(n):
	s[i] = input()
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if s[i][j] == s[i - 1][j - 1] == s[i - 1][j + 1] == s[i + 1][j - 1] == s[i + 1][j + 1] == 'X':
			c += 1
print(c)


n = int(input())
field = []
chests = 0
for i in range(n):
	field.append(list(input().strip()))
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if field[i][j] == field[i - 1][j - 1] == field[i - 1][j + 1] == field[i + 1][j - 1] == field[i + 1][j + 1] == 'X':
			chests += 1
print(chests)


n = int(input())
m = []
for i in range(n):
	r = input()
	m.append(r)
c = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if m[i][j] == m[i - 1][j - 1] and m[i][j] == m[i - 1][j + 1] and (m[i][j] == m[i + 1][j - 1]) and (m[i][j] == m[i + 1][j + 1]) and (m[i][j] == 'X'):
			c += 1
print(c)


n = int(input())
lines = []
for i in range(n):
	lines.append(input())
num_crosses = 0
for x in range(1, n - 1):
	for y in range(1, n - 1):
		if lines[x][y] == 'X' and lines[x - 1][y - 1] == 'X' and (lines[x - 1][y + 1] == 'X') and (lines[x + 1][y + 1] == 'X') and (lines[x + 1][y - 1] == 'X'):
			num_crosses += 1
print(num_crosses)


n = int(input())
A = list([0] * n)
x = 0
for i in range(0, n):
	A[i] = list(input())
for i in range(1, n - 1):
	for j in range(1, n - 1):
		M = 'X'
		if A[i][j] == M and A[i + 1][j + 1] == M and (A[i - 1][j - 1] == M) and (A[i + 1][j - 1] == M) and (A[i - 1][j + 1] == M):
			x += 1
print(x)


a = []
n = int(input())
for _ in range(n):
	a.append(list(input()))
x = 'X'
c = 0
if n >= 3:
	for i in range(n - 2):
		for j in range(n - 2):
			p = [a[i][j:j + 3], a[i + 1][j:j + 3], a[i + 2][j:j + 3]]
			if p[0][0] == x and p[0][2] == x and (p[2][0] == x) and (p[2][2] == x) and (p[1][1] == x):
				c += 1
print(c)


from collections import deque
import pdb
from pprint import pprint

def rI():
	return [int(i) for i in input().split()]
n = rI()[0]
dat = [None for i in range(n)]
for i in range(n):
	dat[i] = input() + '.'
dat.append(''.join(['.' for i in range(n + 1)]))
out = 0
for i in range(n):
	for j in range(n):
		if dat[i][j] == 'X' and dat[i - 1][j - 1] == 'X' and (dat[i - 1][j + 1] == 'X') and (dat[i + 1][j - 1] == 'X') and (dat[i + 1][j + 1] == 'X'):
			out += 1
print(out)


from sys import stdin
n = int(stdin.readline().strip())
s = [stdin.readline().strip() for i in range(n)]
ans = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if s[i][j] == 'X' and s[i - 1][j - 1] == 'X' and (s[i + 1][j + 1] == 'X') and (s[i - 1][j + 1] == 'X') and (s[i + 1][j - 1] == 'X'):
			ans += 1
print(ans)


n = int(input())
m = [[i for i in range(n)] for i in range(n)]
inp = []
for i in range(n):
	inp.append(input())
for i in range(n):
	for j in range(n):
		m[i][j] = inp[i][j]
ct = 0
for p in range(1, n - 1):
	for q in range(1, n - 1):
		if m[p][q] == 'X':
			if m[p - 1][q - 1] == m[p + 1][q + 1] and m[1 + p][q + 1] == 'X':
				if m[p + 1][q - 1] == m[p - 1][q + 1] and m[p - 1][q + 1] == 'X':
					ct += 1
		q += 1
	p += 1
print(ct)


import sys
data = sys.stdin.read().splitlines()
n = int(data[0])
grid = [line for line in data[1:]]
cnt = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if grid[i][j] == grid[i - 1][j - 1] == grid[i - 1][j + 1] == grid[i + 1][j - 1] == grid[i + 1][j + 1] == 'X':
			cnt += 1
print(cnt)


n = int(input())
l = [[0 for j in range(n)] for i in range(n)]
for i in range(n):
	l[i] = input().strip()
ct = 0
if n <= 2:
	print(ct)
else:
	for i in range(1, n - 1):
		for j in range(1, n - 1):
			if l[i][j] == l[i - 1][j - 1] == l[i - 1][j + 1] == l[i + 1][j - 1] == l[i + 1][j + 1] == 'X':
				ct = ct + 1
	print(ct)


n = int(input())
arr = [input() for i in range(n)]
crosses = 0
for i in range(1, n - 1):
	for j in range(1, n - 1):
		test = arr[i - 1][j - 1] + arr[i + 1][j - 1] + arr[i - 1][j + 1] + arr[i + 1][j + 1] + arr[i][j]
		if test == 'XXXXX':
			crosses += 1
print(crosses)


n = int(input())
mat = []
res = 0
for s in range(n):
	mat.append(list(input()))
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if mat[i][j] == mat[i - 1][j - 1] == mat[i - 1][j + 1] == mat[i + 1][j - 1] == mat[i + 1][j + 1] == 'X':
			res += 1
print(res)


n = int(input())
m = ['' for _ in range(n)]
if n > 3:
	for i in range(n):
		m[i] = input()
	xs = 0
	for i in range(n):
		for j in range(n):
			if (i > 0 and j > 0) and (i < n - 1 and j < n - 1):
				if m[i][j] == 'X':
					if m[i - 1][j - 1] == 'X':
						if m[i - 1][j + 1] == 'X':
							if m[i + 1][j - 1] == 'X':
								if m[i + 1][j + 1] == 'X':
									xs += 1
	print(xs)
else:
	print(0)


a = int(input())
A = []
B = []
for i in range(a):
	A.append(input())
if a < 3:
	print(0)
else:
	k = 0
	for i in range(1, a - 1):
		for j in range(1, a - 1):
			if A[i][j] == 'X' and A[i - 1][j - 1] == 'X' and (A[i - 1][j + 1] == 'X') and (A[i + 1][j - 1] == 'X') and (A[i + 1][j + 1] == 'X'):
				k += 1
	print(k)


n = int(input())
count = 0
a = [0 for i in range(n)]
for i in range(n):
	a[i] = input()
for i in range(1, n - 1):
	for j in range(1, n - 1):
		if a[i][j] == a[i - 1][j - 1] == a[i + 1][j - 1] == a[i - 1][j + 1] == a[i + 1][j + 1] == 'X':
			count += 1
print(count)


n = int(input())
matrix = []
for i in range(n):
	matrix.append(input())
	total = 0
for i in range(1, n - 1, 1):
	for j in range(1, n - 1, 1):
		if matrix[i][j] == 'X' and matrix[i - 1][j - 1] == 'X' and (matrix[i + 1][j + 1] == 'X') and (matrix[i + 1][j - 1] == 'X') and (matrix[i - 1][j + 1] == 'X'):
			total += 1
print(total)