Problem: Taro loves chocolate and when he returns from school he eats his favorite chocolate bar with a heart symbol on it. A recent pleasure is to eat all the heart symbol blocks to the end. Taro , Try to eat as many heartless blocks as possible, with all heartmark blocks connected.

<image>

However, Taro is still young, and even if he tries to eat as above, useless blocks will remain. Therefore, Taro seeks the maximum number of blocks that can be eaten when all the heart-shaped blocks are left connected. I asked you to create a program.

Taro can eat whatever way he wants, as long as all the heart-shaped blocks are connected. If one side of one block does not touch the other block, it will be separated.



Input

The input consists of multiple datasets, each dataset given in the following format:


H W
H x W numbers


H and W are integers indicating the vertical size and horizontal size of the chocolate bar, respectively. H x W numbers represent block information, '0' representing blocks without a heart mark, and blocks with a heart mark. Consists of '1'.

The end of the input is indicated by the dataset where H = W = 0. Do not output for this case.

You can assume that 1 ≤ H, W ≤ 12 and the number of heart-shaped blocks is 6 or less.

Output

For each dataset, output the maximum number of blocks that Taro can eat.

Example

Input

4 4
1 0 0 0
0 0 1 0
0 1 0 0
1 0 0 1
1 1
1
2 3
1 0 0
0 0 1
0 0


Output

7
0
2

Solution (in CPP):

Solution:
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef vector<int> vec;
typedef vector<vec> mat;

const int INF = 1e8;
const int dy[] = {-1,0,1,0}, dx[] = {0,1,0,-1};

int min_steiner_tree(mat d, vector<int> t){
  int n = d.size(), m = t.size();
  if(m<=1)return 0;

  rep(k,n)rep(i,n)rep(j,n)d[i][j] = min(d[i][j],d[i][k]+d[k][j]);

  mat dp(1<<m,vec(n,INF));
  rep(i,m)rep(j,n)dp[1<<i][j] = d[t[i]][j];

  rep(s,1<<m){
    if(!(s & (s-1)))continue;
    rep(p,n){
      int sub = s;
      do{
	dp[s][p] = min(dp[s][p], dp[sub][p] + dp[s-sub][p]);
	sub = (sub-1)&s;
      }while(sub!=s);
    }

    rep(p,n)rep(q,n){
      dp[s][p] = min(dp[s][p], dp[s][q] + d[p][q]);
    }
  }

  int ans = INF;
  rep(s,1<<m)rep(p,n){
    ans = min(ans, dp[s][p] + dp[(1<<m)-1-s][p]);
  }

  return ans;
}

int main(){
  int h,w;
  while(cin >> h >> w,h){
    mat d(h*w,vec(w*w,INF));
    vector<int> t;
    int a;
    rep(i,h)rep(j,w){
      cin >> a;
      int p = i*w+j;
      if(a)t.push_back(p);
      rep(k,4){
	int ny = i+dy[k], nx = j+dx[k];
	if(ny<0 || nx<0 || ny>=h || nx>=w)continue;
	d[p][ny*w+nx] = 1;
      }
      d[p][p] = 0;
    }

    if(t.empty())cout << h*w << endl;
    else cout << h*w-1-min_steiner_tree(d,t) << endl;
  }
}