I. Improving the Neighborhood
time limit per test
0.5 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

As part of the expansion of the neighborhood where John lives, new houses have been built for sale, and schools and parks have been established. The neighborhood aims to attract families with children to enjoy the new facilities. To achieve this, the construction company has decided that when a family purchases a house, they will be gifted with the services of one school and one park in the neighborhood. However, to make the most of the services, they will not gift the same school or park to two different families.

The construction company has not received the response they expected with their promotion, so they conducted a series of surveys to determine why families choose to buy houses elsewhere. The surveys revealed that families prefer not to buy a house if they have to travel a distance greater than $$$D$$$ from their house to the school or park. The construction company has decided to change their offer and ensure that the free service they provide to families complies with this restriction. In other words, if a family buys a house, the construction company will provide them with the gift of a school and a park within a distance of no more than $$$D$$$ from their purchased house. From each cell in the map, a family can only move left, right, up or down to an adjacent cell. The distance between two consecutive cells is $$$1$$$. Families are only allowed to walk on "Transitable Spaces" when moving between their cells.

These recent changes have made the construction company concerned, as it seems that with these restrictions, there may be houses that cannot be sold because they cannot fulfill the promotion. That is why they have come to seek your help. Given the map of the neighborhood, which marks the accessible locations, the locations of the new houses, the locations of the parks and schools, and the distance $$$D$$$, your task is to determine the maximum number of new houses that can be sold.

Input

The first line of input contains three integers separated by a space $$$R$$$, $$$C$$$, and $$$D$$$ ($$$1 \leq R,C \leq 30$$$), $$$1 \leq D \leq 1000$$$, representing the number of rows, the number of columns in the map, and the maximum distance a family wills to walk when going from the house to school, or from house to park, respectively. Each of the next $$$R$$$ lines contains a string consisting of exactly $$$C$$$ characters. Each character will be one of '.', '#', 'H', 'S', or 'P'. Representing a transitable space in the neighborhood, an untransitable space in the neighborhood, a new house, a new school, and a new park. Respectively.

Output

Print a line with a single integer number, the maximum number of new houses the construction can sell.

Examples
Input
2 5 10
S.#.P
SHH.P
Output
0
Input
4 4 4
PP..
..H.
..H.
SS..
Output
2
Input
4 4 10
PP..
##H.
..H.
SS..
Output
1