Problem: You got an old map, which turned out to be drawn by the infamous pirate "Captain Q". It shows the locations of a lot of treasure chests buried in an island.

The map is divided into square sections, each of which has a digit on it or has no digit. The digit represents the number of chests in its 9 neighboring sections (the section itself and its 8 neighbors). You may assume that there is at most one chest in each section.

Although you have the map, you can't determine the sections where the chests are buried. Even the total number of chests buried in the island is unknown. However, it is possible to calculate the minimum number of chests buried in the island. Your mission in this problem is to write a program that calculates it.



Input

The input is a sequence of datasets. Each dataset is formatted as follows.

h w
map

The first line of a dataset consists of two positive integers h and w. h is the height of the map and w is the width of the map. You may assume 1≤h≤15 and 1≤w≤15.

The following h lines give the map. Each line consists of w characters and corresponds to a horizontal strip of the map. Each of the characters in the line represents the state of a section as follows.

'.': The section is not a part of the island (water). No chest is here.

'*': The section is a part of the island, and the number of chests in its 9 neighbors is not known.

'0'-'9': The section is a part of the island, and the digit represents the number of chests in its 9 neighbors.

You may assume that the map is not self-contradicting, i.e., there is at least one arrangement of chests. You may also assume the number of sections with digits is at least one and at most 15.

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

Output

For each dataset, output a line that contains the minimum number of chests. The output should not contain any other character.

Examples

Input

5 6


Output

6


Input

5 6
*2.2**
..*...
..2...
..*...
*2.2**
6 5
.*2*.
..*..
..*..
..2..
..*..
.*2*.
5 6
.1111.
**...*
33....
**...0
.*2**.
6 9
....1....
...1.1...
....1....
.1..*..1.
1.1***1.1
.1..*..1.
9 9
*********
*4*4*4*4*
*********
*4*4*4*4*
*********
*4*4*4*4*
*********
*4*4*4***
*********
0 0


Output

6
5
5
6
23

Solution (in CPP):

Solution:
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;
typedef pair<int, int> pii;
typedef unsigned long long ull;

const int INF = 1000000000;
const int dx[] = { -1, 0, 1, -1, 0, 1, -1, 0, 1 };
const int dy[] = { -1, -1, -1, 0, 0, 0, 1, 1, 1 };

bool between(int a, int b, int c){
	return a <= b && b < c;
}
bool valid_count(ull v){
	const ull m = 0x1111111111111111ull;
	return (v & (v >> 1) & (v >> 2) & (v >> 3) & m) == 0;
}

map< pair<ull, pii>, int > memo;
int recur(
	ull count, int y, int x, const vector< vector<ull> > &dec,
	const vector< vector<ull> > &cutmask)
{
	map< pair<ull, pii>, int >::iterator it =
		memo.find(make_pair(count, pii(y, x)));
	if(it != memo.end()){ return it->second; }
	int h = dec.size(), w = dec[0].size();
	if(y == h){ return count != 0 ? INF : 0; }
	if(count & cutmask[y][x]){ return INF; }
	int ny = (x + 1 == w ? y + 1 : y), nx = (x + 1 == w ? 0 : (x + 1));
	int answer = INF;
	if(dec[y][x] != 0ull){
		ull nc = count - dec[y][x];
		if(valid_count(nc)){
			answer = 1 + recur(nc, ny, nx, dec, cutmask);
		}
	}
	answer = min(answer, recur(count, ny, nx, dec, cutmask));
	memo.insert(make_pair(make_pair(count, pii(y, x)), answer));
	return answer;
}

int main(){
	while(true){
		int h, w;
		cin >> h >> w;
		if(h == 0 && w == 0){ break; }
		vector<string> field(h);
		for(int i = 0; i < h; ++i){ cin >> field[i]; }
		vector< vector<int> > hint(h, vector<int>(w, -1));
		ull init_count = 0;
		for(int i = 0, hi = 0; i < h; ++i){
			for(int j = 0; j < w; ++j){
				if(isdigit(field[i][j])){
					hint[i][j] = hi;
					init_count |= ((ull)field[i][j] - '0') << hi * 4;
					++hi;
				}
			}
		}
		vector< vector<ull> > dec(h, vector<ull>(w));
		for(int i = 0; i < h; ++i){
			for(int j = 0; j < w; ++j){
				if(field[i][j] != '.'){
					ull vec = 0;
					for(int k = 0; k < 9; ++k){
						int y = i + dy[k], x = j + dx[k];
						if(!between(0, y, h) || !between(0, x, w)){ continue; }
						if(hint[y][x] < 0){ continue; }
						vec |= (1ull << hint[y][x] * 4);
					}
					dec[i][j] = vec;
				}
			}
		}
		vector< vector<ull> > cutmask(h, vector<ull>(w));
		for(int i = 0; i < h; ++i){
			for(int j = 0; j < w; ++j){
				if(hint[i][j] < 0){ continue; }
				int x = j + 2, y = i + 1;
				if(x >= w){ x = 0; ++y; }
				if(y < h){ cutmask[y][x] |= 0x0full << (hint[i][j] * 4); }
			}
		}
		memo.clear();
		cout << recur(init_count, 0, 0, dec, cutmask) << endl;
	}
	return 0;
}