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"

#pragma warning(disable:4996)
using namespace std;
using ld = long double;

namespace shniter {
	using Value=int;
	using Edge=pair<int,Value>;
	using Graph=vector<vector<Edge>>;
	const Value inf = 1<<20;

	vector<vector<Value>>w_h(const Graph&g) {
		vector<vector<Value>>asps(g.size(),vector<Value>(g.size(),1e9));
		for (int i = 0; i < g.size(); ++i) {
			for (auto e : g[i]) {
				asps[i][e.first]=e.second;
			}
			asps[i][i]=0;
		}

		for (int k = 0; k < g.size(); ++k) {
			for (int i = 0; i < g.size(); ++i) {
				for (int j = 0; j < g.size(); ++j) {
					asps[i][j]=min(asps[i][k]+asps[k][j],asps[i][j]);
				}
			}
		}
		return asps;
	}

	//最小シュナイター木
	Value solve(const Graph&g, const vector<int>shs) {
		//全点対最短経路(APSP : all pair shortest paths)
		auto asps = w_h(g);
		vector<vector<Value>>OPT(1 << shs.size(), vector<Value>(g.size(), inf));


		for (int p = 0; p < shs.size(); ++p) // trivial case
			for (int q = 0; q < g.size(); ++q){
				OPT[1 << p][q] = asps[shs[p]][q];
				OPT[0][q] = 0;
			}


		for (int k = 1; k < (1 << shs.size()); ++k) {
			for (int root = 0; root < g.size(); ++root) {
				if(!(k&(k-1)))continue;

				for (int e = 0; e < k; ++e) {
					if ((e | k) == k) {
						OPT[k][root] = min(OPT[k][root], OPT[e][root] + OPT[e^k][root]);
					}
				}
				
			}

			for (int p = 0; p < g.size(); ++p) {
				for (int q = 0; q < g.size(); ++q) {
					OPT[k][p] = min(OPT[k][p],
						OPT[k][q] + asps[p][q]);
				}
			}
		}
		Value ans = inf;
		for (int S = 0; S < (1 << shs.size()); ++S)
			for (int q = 0; q < g.size(); ++q)
				ans = min(ans, OPT[S][q] + OPT[((1 <<shs.size())-1 - S)][q]);

		return ans;
	}
}
int H,W;
int get_id(int x, int y) {
	if(x<0||W<=x||y<0||y>=H)return -1;
	else return y*W+x;
}

int main() {
	while (true) {
		cin>>H>>W;
		if(!H)break;
		vector<vector<int>>field(H,vector<int>(W));
		vector<int>storoberry_ids;
		for (int i = 0; i < H; ++i) {
			for (int j = 0; j < W; ++j) {
				cin>>field[i][j];
				if (field[i][j]) {
					storoberry_ids.push_back(get_id(j,i));
				}
			}
		}
		using namespace shniter;
		Graph g(H*W);
		for (int y = 0; y < H; ++y) {
			for (int x = 0; x < W; ++x) {
				for (int way = 0; way < 4; ++way) {
					int dx[] = { -1,0,1,0 };
					int dy[] = { 0,1,0,-1 };
					int nx=x+dx[way];
					int ny=y+dy[way];
					int nid=get_id(nx,ny);
					int id=get_id(x,y);
					if (nid != -1) {
						g[id].push_back(Edge(nid,1));
					}
				}
			}
		}
		Value answer=solve(g,storoberry_ids);
		cout<<H*W-(answer+1)<<endl;
	}
	return 0;
}