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 <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> P;
typedef pair<vi,int> Vii;
typedef long long ull;
ull B=1e7+7;
int dx[9]={-1,-1,-1,0,0,0,1,1,1},dy[9]={-1,0,1,-1,0,1,-1,0,1};
int H,W,I;
string s[15];
int id[15][15];
vector<int> ns;
vi nei[15][15];
vi htons[15];
map<int,int> mp;
int myhash(int h,int w){
	ull s=h*W+w;
	rep(i,I) s=s*B+ns[i];
	return (int)s;
}
void init(int H,int W){
	I=0;
	rep(i,H) rep(j,W) id[i][j]=-1;
	ns.clear();
	rep(i,H) rep(j,W) nei[i][j].clear();
	rep(i,H) htons[i].clear();
	mp.clear();
}
bool is(int x,int y){
	return 0<=x and x<H and 0<=y and y<W;
}
bool put(int h,int w){
	for(int v:nei[h][w]){
		if(ns[v]==0) return false;
	}
	for(int v:nei[h][w]) ns[v]--;
	return true;
}
void rmv(int h,int w){
	for(int v:nei[h][w]) ns[v]++;
}
bool linecheck(int h){
	if(h<0) return 1;
	for(int n:htons[h]) if(ns[n]!=0) return 0;
	return 1;
}
bool ok(){
	for(int n:ns) if(n!=0) return false;
	return true;
}
int dfs(int h,int w){
	if(w==W){
		if(!linecheck(h-1)) return 114514;
		return dfs(h+1,0);
	}
	if(h==H){
		if(ok()) return 0;
		else return 114514;
	}
	if(s[h][w]=='.'||nei[h][w].empty()) return dfs(h,w+1);
	if( mp.count(myhash(h,w))) return mp[myhash(h,w)];
	int ret=dfs(h,w+1);
	if(put(h,w)){
		chmin(ret,dfs(h,w+1)+1);
		rmv(h,w);
	}
	mp[myhash(h,w)]=ret;
	return ret;
}
int main(){
	while(true){
		cin>>H>>W;
		if(H==0) break;
		rep(i,H) cin>>s[i];
		if(H<W){
			string st[15];
			rep(i,H) st[i]=s[i];
			rep(i,W) s[i].resize(H);
			rep(i,W) rep(j,H) s[i][j]=st[j][i];
			swap(H,W);
		}
		init(H,W);
		rep(i,H) rep(j,W) if(isdigit(s[i][j])){
			id[i][j]=I++;
			ns.pb(s[i][j]-'0');
			htons[i].pb(id[i][j]);
		}
		rep(i,H) rep(j,W){
			rep(d,9){
				int ni=i+dx[d],nj=j+dy[d];
				if(is(ni,nj)&&isdigit(s[ni][nj])) nei[i][j].pb(id[ni][nj]);
			}
		}
		cout<<dfs(0,0)<<endl;
	}
}