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>
using namespace std;
#define REP(i,a,n) for(int i=a;i<n;i++)
#define mat vector<vector<int> >
struct Minimum_Steiner_Tree{
	mat V;
	vector<int>T;
	int n,numT,Inf=1e8;
	Minimum_Steiner_Tree(int sz):n(sz),numT(0),V(sz,vector<int>(sz)){
		REP(i,0,sz)REP(j,0,sz)V[i][j]=(i==j?0:Inf);
	}
	void add_edge(int a,int b,int c){ V[a][b]=V[b][a]=c; }
	void add_vertex(int a){ T.push_back(a); numT++;}
	int build(){
		if(numT<=1)return 0;
		mat d(V);
		REP(k,0,n)REP(i,0,n)REP(j,0,n)d[i][j]=min( d[i][j], d[i][k] + d[k][j] );
		int OPT[(1<<numT)][n];
		REP(i,0,(1<<numT))REP(j,0,n)OPT[i][j]=Inf;
		REP(i,0,numT)REP(j,0,n)OPT[1<<i][j]=d[T[i]][j];
		REP(S,1,(1<<numT))if(S&(S-1)){
			REP(i,0,n)REP(j,0,S)if((S|j)==S) OPT[S][i] = min( OPT[S][i], OPT[j][i] + OPT[S-j][i] );
			REP(i,0,n)REP(j,0,n) OPT[S][i] = min( OPT[S][i], OPT[S][j] + d[i][j] );
		}
		int ans=Inf;
		REP(i,0,(1<<numT))REP(j,0,n)ans = min(ans, OPT[i][j] + OPT[((1 << numT)-1)-i][j]);
		return n-ans-1;
	}
};
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
int main(){
	int h,w,t;
	while(cin>>h>>w,h){
		Minimum_Steiner_Tree M(h*w);
		REP(i,0,h)REP(j,0,w){
			cin>>t;
			if(t)M.add_vertex(i*w+j);
			REP(k,0,4){
				int y=i+dy[k];
				int x=j+dx[k];
				if(y<0||x<0||y>=h||x>=w)continue;
				M.add_edge(i*w+j,y*w+x,1);
			}
		}
		cout<<M.build()<<endl;
	}
}