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<cstdio>
#include<algorithm>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

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

const int N_MAX=144,T_MAX=6;
int Dreyfus_Wagner(int n,int d[N_MAX][N_MAX],int nt,int *t){
	rep(k,n) rep(i,n) rep(j,n) d[i][j]=min(d[i][j],d[i][k]+d[k][j]);

	static int dp[1<<T_MAX][N_MAX];
	rep(S,1<<T_MAX) rep(i,n) dp[S][i]=INF;
	rep(i,nt) rep(j,n) dp[1<<i][j]=d[t[i]][j];

	rep(S,1<<nt) if(S && S&S-1) { // |S|>=2
		for(int T=S-1&S;T;T=T-1&S) rep(p,n) {
			dp[S][p]=min(dp[S][p],dp[T][p]+dp[S&~T][p]);
		}
		rep(p,n) rep(q,n) dp[S][p]=min(dp[S][p],dp[S][q]+d[p][q]);
	}

	return dp[(1<<nt)-1][t[0]];
}

int main(){
	for(int h,w;scanf("%d%d",&h,&w),h;){
		int d[N_MAX][N_MAX];
		rep(i,h) rep(j,w) rep(y,h) rep(x,w) d[i*w+j][y*w+x]=(i==y&&j==x?0:INF);

		int n=0,heart[6];
		rep(i,h) rep(j,w) {
			int choco; scanf("%d",&choco);
			if(choco) heart[n++]=i*w+j;
			rep(k,4){
				int y=i+dy[k],x=j+dx[k];
				if(0<=y && y<h && 0<=x && x<w) d[i*w+j][y*w+x]=1;
			}
		}

		printf("%d\n",h*w-Dreyfus_Wagner(h*w,d,n,heart)-1);
	}

	return 0;
}