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 <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

struct Status {
  int use;
  int pnum[20];
  bool operator<(const Status &rhs) const {
    if (use != rhs.use) { return use < rhs.use; }
    return memcmp(pnum, rhs.pnum, sizeof(pnum)) < 0;
  }
};

int h, w;
int n;
int pnum[20];
int px[20];
int py[20];
char bomb[15][15];
char field[20][20];
map<Status, int> memo;
int dx[9] = { -1, 0, 1, -1, 0, 1, -1, 0, 1 };
int dy[9] = { -1, -1, -1, 0, 0, 0, 1, 1, 1 };

int calc(int depth, Status &status);
int NextState(int depth, Status &status, int cnt) {
  if (cnt == 9) {
    if (status.pnum[depth] != 0) { return 1 << 30; }
    status.use ^= 1 << depth;
    int ret = calc(depth + 1, status);
    status.use ^= 1 << depth;
    return ret;
  }
  int x = px[depth] + dx[cnt];
  int y = py[depth] + dy[cnt];
  if (x < 0 || x >= w || y < 0 || y >= h || field[y][x] == '.' || bomb[y][x] != 0) { return NextState(depth, status, cnt + 1); }

  int ret = 1 << 30;
  bomb[y][x] = 1;
  ret = min(ret, NextState(depth, status, cnt + 1));
  bool ng = false;
  REP(i, n) {
    if (abs(x - px[i]) > 1 || abs(y - py[i]) > 1) { continue; }
    status.pnum[i]--;
    if (status.pnum[i] < 0) { ng = true; }
  }
  if (!ng) {
    ret = min(ret, NextState(depth, status, cnt + 1) + 1);
  }
  REP(i, n) {
    if (abs(x - px[i]) > 1 || abs(y - py[i]) > 1) { continue; }
    status.pnum[i]++;
  }
  bomb[y][x] = 0;
  return ret;
}

int calc(int depth, Status &status) {
  if (depth == n) { return 0; }
  if (memo.count(status)) { return memo[status]; }
  int ret = NextState(depth, status, 0);
  return memo[status] = ret;
}

int main() {
  while (scanf("%d %d", &h, &w), h|w) {
    memo.clear();
    REP(y, h) {
      scanf("%s", field[y]);
    }
    n = 0;
    REP(y, h) {
      REP(x, w) {
        if (isdigit(field[y][x])) {
          pnum[n] = field[y][x] - '0';
          px[n] = x;
          py[n] = y;
          n++;
        }
      }
    }
    Status status;
    status.use = 0;
    memcpy(status.pnum, pnum, sizeof(pnum));
    //MEMSET(status.bomb, 0);
    int ans = calc(0, status);
    printf("%d\n", ans);
  }
}