#t312. 流感传染

流感传染

Flu Spread

Problem Background

Special for beginners, ^_^

Problem Description

A group of susceptible people live in a grid-shaped dormitory area, which is an n×nn \times n matrix. Each grid point is a room that may be occupied or empty. On the first day, some people in certain rooms catch the flu. Each subsequent day, a person with the flu infects their neighbors (those already sick do not change), while empty rooms are not contagious.

Output the number of people with the flu on day mm.

Input Format

The first line contains an integer nn (not exceeding 100), representing an n×nn \times n dormitory grid.

The next nn lines each contain nn characters: . means the room is occupied by a healthy person on day 1, # means the room is empty, @ means the room is occupied by a person with the flu on day 1.

The following line contains an integer mm (not exceeding 100).

Output Format

Output the number of people with the flu on day mm.

Sample Input

5
. . . . #
. # . @ .
. # @ . .
# . . . .
. . . . .
4

Sample Output

16

Constraints

1 second, 1024 KiB for each test case.