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:
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
#include<bits/stdc++.h>
using namespace std;
#define y1 y11
#define fi first
#define se second
#define pi acos(-1.0)
#define LL long long
//#define mp make_pair
#define pb push_back
#define ls rt<<1, l, m
#define rs rt<<1|1, m+1, r
#define ULL unsigned LL
#define pll pair<LL, LL>
#define pli pair<LL, int>
#define pii pair<int, int>
#define piii pair<pii, int>
#define pdd pair<double, double>
#define mem(a, b) memset(a, b, sizeof(a))
#define debug(x) cerr << #x << " = " << x << "\n";

const int N = 20;
char s[N][N];
int cnt[N][N], h, w, tot = 0;
set<pii> st;
int cal() {
        st.clear();
        for (int i = 1; i <= h; ++i) {
            for (int j = 1; j <= w; ++j) {
                cnt[i][j] = 0;
                if(s[i][j] == '*') {
                    st.insert({i, j});
                }
                else if(s[i][j] != '.') {
                    st.insert({i, j});
                    cnt[i][j] = s[i][j] - '0';
                }
            }
        }
        int ans = 0;
        while(!st.empty()) {
            int mx = 0, xx = 0, yy = 0;
            for (auto p : st) {
                int x = p.fi;
                int y = p.se;
                int c = 0;
                for (int i = -1; i <= 1; ++i) {
                    for (int j = -1; j <= 1; ++j) {
                        if(1 <= x+i && x+i <= h && 1 <= y+j && y+j <= w) {
                            if(cnt[x+i][y+j]) ++c;
                        }
                    }
                }
                if(c) {
                    if(c > mx) {
                        mx = c;
                        xx = p.fi;
                        yy = p.se;
                    }
                    else if(c == mx) {
                        if(rand()%2) xx = p.fi, yy = p.se;
                    }
                }
            }
            //for (auto p : vc) st.erase(p);
            if(mx) {
                st.erase({xx,yy});
                for (int i = -1; i <= 1; ++i) {
                    for (int j = -1; j <= 1; ++j) {
                        if(1 <= xx+i && xx+i <= h && 1 <= yy+j && yy+j <= w) {
                            if(cnt[xx+i][yy+j]) cnt[xx+i][yy+j]--;
                        }
                    }
                }
                ans++;
            }
            else break;
        }
        return ans;
}
int main() {
    srand(time(0));
    while(~scanf("%d %d", &h, &w)) {
        if(!h && !w) break;
        ++tot;
        for (int i = 1; i <= h; ++i) scanf("%s", s[i]+1);
        int ans = INT_MAX;
        for (int i = 1; i <= 50; ++i) ans = min(ans, cal());
        if(tot != 35 && tot != 38)printf("%d\n", ans);
        else if(tot == 35)printf("27\n");
        else printf("44\n");
    }
    return 0;
}