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 <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
typedef pair<int, vector<int> > P;
map<P, int> memo;
int dfs(int k, vector<int>& cur, const vector<int>& s, map<int, int>& cnt){
  int L = cur.size(), N = s.size();
  P p(k, cur);
  if(memo.count(p)) return memo[p];
  int& res = memo[p];
  res = INF;
  int S = s[k];
  for(int i = L - 1; i >= 0; i--){
    if(S >> i & 1) break;
    if(cur[i] != 0) return res;
  }
  if(k + 1 == N) return res = 0;
  int use = cnt[S];
  for(int i = 0; i < L; i++) if(S >> i & 1) use = min(use, cur[i]);
  for(int i = 0; i <= use; i++){
    vector<int> tmp = cur;
    for(int j = 0; j < L; j++) if(S >> j & 1) cur[j] -= i;
    res = min(res, dfs(k + 1, cur, s, cnt) + i);
    cur = tmp;
  }
  //printf("dfs(S = %d) : ", S); REP(i, L) cout << cur[i] << " "; cout << endl;
  return res;
}
int main(){
  int H, W;
  while(cin >> H >> W && H){
    memo.clear();
    map<int, int> cnt;
    vector<int> s;
    vector<string> grid(H);
    REP(y, H) cin >> grid[y];
    vector<int> mx, my;
    vector<int> cur;
    REP(y, H)REP(x, W)if(isdigit(grid[y][x])){
      mx.push_back(x);
      my.push_back(y);
      cur.push_back(grid[y][x] - '0');
    }
    int L = mx.size();
    REP(y, H)REP(x, W)if(grid[y][x] != '.'){
      int S = 0;
      REP(i, L)if(abs(mx[i] - x) <= 1 && abs(my[i] - y) <= 1){
        S |= 1 << i;
      }
      cnt[S] += 1;
      if(cnt[S] == 1) s.push_back(S);
    }
    s.push_back(0); //last
    sort(s.begin(), s.end());
    reverse(s.begin(), s.end());
    cout << dfs(0, cur, s, cnt) << endl;
  }
  return 0;
}