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<stdio.h>
#include<algorithm>
#include<map>
using namespace std;
char str[17][17];
int dx[]={-1,-1,-1,0,0,0,1,1,1};
int dy[]={-1,0,1,-1,0,1,-1,0,1};
int v[17][17];
int u[17][17];
int row[310];
int col[310];
int sz;
int n,m;
struct wolf{
	long long t;
	int s;
	wolf(){t=0;s=0;}
};
inline bool operator<(const wolf&a,const wolf&b){
	if(a.t!=b.t)return a.t<b.t;
	return a.s<b.s;
}
long long pow10[19];
inline int ABS(int a){return max(a,-a);}
int ret=99999999;
int id;
int ir[20];
int ic[20];
map<wolf,int>dp;
int solve(int a,wolf b){
	if(dp.count(b))return dp[b];
//	printf("%d %lld %d\n",a,b.t,c);
	bool dame=false;
	for(int i=0;i<id;i++){
		int cnt=0;
		for(int j=a;j<sz;j++){
			if(ABS(ir[i]-row[j])<=1&&ABS(ic[i]-col[j])<=1)cnt++;
		}
		if(cnt<b.t%pow10[i+1]/pow10[i]){dame=true;break;}
	}
	if(dame){
		return dp[b]=99999999;
	}
	if(a==sz){
		return dp[b]=0;
	}
	int ret=99999999;
	
	b.s++;
	bool ok=true;
	for(int i=0;i<id;i++){
		if(ABS(ir[i]-row[a])<=1&&ABS(ic[i]-col[a])<=1&&b.t%pow10[i+1]/pow10[i]==0)ok=false;
	}
	//printf("%d %lld %d %d\n",a,b.t,ok,c);
	if(ok){
		for(int i=0;i<id;i++){
			if(ABS(ir[i]-row[a])<=1&&ABS(ic[i]-col[a])<=1)b.t-=pow10[i];
		}
		ret=min(ret,solve(a+1,b)+1);
		for(int i=0;i<id;i++){
			if(ABS(ir[i]-row[a])<=1&&ABS(ic[i]-col[a])<=1)b.t+=pow10[i];
		}	
	}
	ret=min(ret,solve(a+1,b));
	b.s--;
	return dp[b]=ret;
}
int main(){
	int a,b;
	pow10[0]=1;
	for(int i=1;i<19;i++)pow10[i]=pow10[i-1]*10;
	while(scanf("%d%d",&a,&b),a){
		n=a;m=b;
		id=0;
		sz=0;
		dp.clear();
		ret=99999999;
		wolf st;
		for(int i=0;i<a;i++)scanf("%s",str[i]);
		for(int i=0;i<a;i++)for(int j=0;j<b;j++)v[i][j]=u[i][j]=0;
		//for(int i=0;i<a;i++)for(int j=0;j<b;j++)if(str[i][j]=='.')v[i][j]=-1;
		for(int i=0;i<a;i++){
			for(int j=0;j<b;j++){
				if('0'<=str[i][j]&&str[i][j]<='9'){
					ir[id]=i;
					ic[id++]=j;
					st.t+=pow10[id-1]*(str[i][j]-'0');
					v[i][j]=str[i][j]-'0';
					for(int k=0;k<9;k++){
						if(0<=i+dx[k]&&i+dx[k]<a&&0<=j+dy[k]&&j+dy[k]<b&&str[i+dx[k]][j+dy[k]]!='.'){
							u[i+dx[k]][j+dy[k]]++;
						}
					}
				}
			}
		}
	//	for(int k=1;k<=9;k++)
		for(int i=0;i<a;i++)for(int j=0;j<b;j++)if(u[i][j]){
			row[sz]=i;col[sz++]=j;
		}
		printf("%d\n",solve(0,st));
	}
}