### Problem Statement

You are working on a program that randomly generates game boards for the well-known game SweepMines. In SweepMines, your goal is to reveal all cells in a 2-dimensional grid that contain mines. Each cell without a mine contains a digit representing the upper bound on the number of mines that may surround that cell, both orthogonally and diagonally. For example, if an empty cell has 3 neighboring cells with mines, it can contain any number between 3 and 9 (but not 0, 1 or 2). If a cell has no neighboring mines at all, it can contain any digit.

For instance, the board shown to the left is a valid board, while the one on the right is not because there is a mine adjacent to a cell that contains a 0 (here, '*' represents a mine).

```11000          02210
*2921          1****
23**1          03332
*2251          *1000
```

You have already written a subroutine that has filled in the first few randomly chosen cells of the game board, which is given as a String[]. Each cell that your subroutine has generated represents either a blank space or a number representing the maximal number of mines that may surround that cell from the (up to) eight spaces around it. If a cell contains a blank space, then any number of mines may surround that cell. You may only place a mine in a blank cell.

Since you want the game to be as challenging as possible, you wish to find the maximal number of mines that the board may be filled with such that the resulting board configuration is valid. Note that a mine configuration is valid if and only if the number of mines surrounding each original non-blank cell is at most the number inside that cell.

### Definition

 Class: MinePut Method: getMines Parameters: String[] Returns: int Method signature: int getMines(String[] partialBoard) (be sure your method is public)

### Notes

-You may not place a mine in a filled cell; only a blank one.

### Constraints

-partialBoard will contain between 1 and 22 elements, inclusive.
-Each element of partialBoard will contain between 1 and 22 characters, inclusive.
-Each element of partialBoard will contain the same number of characters.
-partialBoard will contain at most 22 characters.
-Each element of partialBoard will contain only digits ('0'-'9') and '.' characters.

### Examples

0)

 ```{ "0050", "0100", "0010", "3000"}```
`Returns: 0`
 It's impossible to place any mines.
1)

 ```{ ".100", "1100", "0000", "0000"}```
`Returns: 1`
 The only possible location for a mine is the upper left corner.
2)

 ```{ ".....", ".....", ".....", "....."}```
`Returns: 20`
 The entire board can be filled with mines.
3)

 ```{ "3.4..1", "2.21..", "999999"}```
`Returns: 3`

#### Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=3454

#### Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=10069&pm=3454

eleusive

#### Testers:

PabloGilberto , brett1479 , Olexiy

#### Problem categories:

Brute Force, Recursion