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$.

Difficulty: interview

Starter code:

Solutions:
n = int(input())

a = [input() for i in range(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)

# list(map(int, input().split()))

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)

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()]

# code goes here
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())
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())
a = []
for i in range(n):
    s = input()
    a.append(s)
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 mi():
    return list(map(int, input().split()))
'''
5
.....
.XXX.
.XXX.
.XXX.
.....
'''
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())
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())
m = []
for i in range(n):
    m.append(input())
x = 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"):
            x+=1
print(x)


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)

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)

n=int(input())
s=[]
a=0
for _ 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':
            a+=1
print(a)

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)

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)

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)

n = int(input())

seq = []
for i in range(n):
    seq.append(list(input()))
# print(seq)
ans = 0
for i in range(1, n - 1):
    for j in range(1, n - 1):
        # print(i, j, seq[i][j])
        if seq[i][j] == "X" and seq[i - 1][j - 1] == "X" and seq[i - 1][j + 1] == "X" and seq[i + 1][j - 1] == "X" and seq[i + 1][j + 1] == "X":
            ans += 1
print(ans)


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())
grid = [input() for _ in range(n)]
total = 0
if n<=2:
    print (total)
    return
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)


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())
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())
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()

n = int(input())
ans = 0
a = []
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':
            ans += 1
print(ans)            


n = int(input())
m = [input() 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)

n = int(input())
s = []
count = 0
for i in range(n):
    s.append(list(input()))
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())
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)