Captain Q's Treasure

No attempts yetTime limit3sMemory limit128 MB

Problem

You have obtained an old map that turns out to have been drawn by the notorious pirate “Captain Q”. It marks the locations of many treasure chests buried on an island.

The map is divided into square cells. Each cell either shows a single digit or shows no digit. A digit on a cell tells how many chests are buried in the 9 cells of its neighborhood (the cell itself together with its 8 surrounding cells). You may assume that each cell holds at most one chest.

Even with the map you cannot tell exactly which cells hold chests, and you do not even know the total number of chests buried on the island. You can, however, compute the minimum possible number of chests. Your task is to write a program that computes this minimum.

Input

The input is a sequence of datasets. Each dataset has the following format.

h w
map

The first line of a dataset contains two positive integers $h$ and $w$: $h$ is the height of the map and $w$ is its width. You may assume $1 \le h \le 15$ and $1 \le w \le 15$.

The next $h$ lines describe the map. Each line has $w$ characters and corresponds to one horizontal strip of the map. Each character encodes the state of a cell as follows.

  • . : the cell is not part of the island (water); no chest is here.
  • * : the cell is part of the island, and the number of chests in its 9 neighbors is unknown.
  • 09 : the cell is part of the island, and the digit is the number of chests in its 9 neighbors.

You may assume that the map is never self-contradicting; that is, at least one valid arrangement of chests exists. You may also assume that the number of cells carrying a digit is at least one and at most 15.

A line containing two zeros marks the end of the input.

Output

For each dataset, print a line containing the minimum number of chests. The output must not contain any other character.