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<iostream>
using namespace std;
#define N 144
#define MAX 16
const int infty = 4096;

/*
 * ref: Spaghetti Source
 * weight minimum_steiner_tree(const vector<int> &T, const matrix * &g);
 */
int MinimumSteinerTree(int nt, int T[], int n, int G[][N]){
  if( nt <= 1 ) return 0;
  int d[n][n];

  for(int i=0;i<n;++i)
    for(int j=0;j<n;++j)
      d[i][j]=G[i][j];

  for(int k=0;k<n;++k)
    for(int i=0;i<n;++i)
      for(int j=0;j<n;++j)
	d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
  
  const int space = 1<<nt;
  int dp[space][n];
  for(int s=0;s<space;++s)
    for(int x=0;x<n;++x)
      dp[s][x]=infty;

  // |S| = 2
  for(int p=0;p<nt;++p)
    for(int q=0;q<n;++q)
      dp[1<<p][q]=d[T[p]][q];
  
  /*
  for(int s=1;s<space;++s){
    if(!(s&(s-1)))continue;
    for(int p=0;p<n;++p)
      for(int e=0;e<s;++e)
	if((e|s)==s)
	  dp[s][p]=min(dp[s][p],dp[e][p]+dp[s-e][p]);
    for(int p=0;p<n;++p)
      for(int q=0;q<n;++q)
	dp[s][p]=min(dp[s][p],dp[s][q]+d[p][q]);
  }
  */
  // |S| >= 2
  for(int s=1;s<space;++s){
    for(int p=0;p<n;++p){
      int tmp = infty;
      for(int q=0;q<n;++q)
	for(int e=0;e<s;++e)
	  if((e|s)==s)
	    tmp = min(tmp,d[p][q]+dp[e][q]+dp[s-e][q]);
      dp[s][p]=min(dp[s][p],tmp);
    }
  }
  
  int ret=infty;
  for(int s=0;s<space;++s)
    for(int q=0;q<n;++q)
      ret=min(ret,dp[s][q]+dp[(space-1)-s][q]);

  return ret;
}

int main()
{
  while(true){
    int H,W;
    int M[MAX][MAX]={{0,},};
    int G[N][N];
    int numChoco=0;
    int T[MAX];
    cin >> H >> W;
    if(H==0&&W==0)break;
    
    for(int i=0;i<H;++i){
      for(int j=0;j<W;++j){
	cin>>M[i][j];
	if(M[i][j]==1){
	  T[numChoco++]=i*W+j;
	}
      }
    }

    const int di[] = {-1,0,1,0};
    const int dj[] = {0,1,0,-1};

    for(int i=0;i<H*W;++i){
      for(int j=0;j<H*W;++j){
	G[i][j]=infty;
      }
    }
    
    for(int i=0;i<H;++i){
      for(int j=0;j<W;++j){
	G[i*W+j][i*W+j]=0;
	for(int k=0;k<4;++k){
	  int ti=i+di[k];
	  int tj=j+dj[k];
	  if(0<=ti&&ti<H&&0<=tj&&tj<W){
	    G[i*W+j][ti*W+tj]=G[ti*W+tj][i*W+j]=1;
	  }
	}
      }
    }
    
    cout << H*W-(MinimumSteinerTree( numChoco, T, H*W, G )+1) << endl;

  }
  return 0;
}