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>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>

// BEGIN CUT HERE
#ifdef _MSC_VER
#include <agents.h>
#endif
// END CUT HERE 

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) begin(v), end(v)
#define REV(v) rbegin(v), rend(v)
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define X first
#define Y second
#define f(x, y) ((y)*w+(x))

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int INF = 1e9;
const int N = 12;
int ch[N][N];
int d[N*N][N*N];
int dp[1 << N][N*N];

int main(){
	int h, w;
	while (cin >> h >> w, h|w){
		vector<int> v;
		rep(i, h) rep(j, w){
			cin >> ch[i][j];
			if (ch[i][j]) v.push_back(f(j, i));
		}

		int n = h*w, t = v.size();
		rep(i, n) rep(j, n) if (i != j) d[i][j] = INF;
		rep(i, h) rep(j, w){
			rep(k, 2){
				int nx = j + k, ny = i + !k;
				if (nx >= w || ny >= w) continue;
				d[f(j, i)][f(nx, ny)] = d[f(nx, ny)][f(j, i)] = 1;
			}
		}
		rep(i, n) rep(j, n) rep(k, n) d[j][k] = min(d[j][k], d[j][i] + d[i][k]);

		rep(i, 1 << t) rep(j, n) dp[i][j] = INF;
		rep(i, t) rep(j, n) dp[1 << i][j] = d[v[i]][j];
		rep(i, 1 << t) rep(p, n) rep(q, n) for (int j = i; j > 0; j = (j - 1)&i) dp[i][p] = min(dp[i][p], dp[i^j][q] + dp[j][q] + d[p][q]);

		int res = INF, all = (1 << t) - 1;
		rep(i, 1 << t) rep(p, n) res = min(res, dp[i][p] + dp[all^i][p]);

		if (res == INF) res = n;
		else ++res;

		cout << h * w - res << endl;
	}

	return 0;
}