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 <algorithm>
#include <cassert>
#include <iomanip>
#include <queue>
#include <iostream>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define DEBUGP(val) cerr << #val << "=" << val << "\n"

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;


const int inf = 1e9;
// Dreyfus-Wagner. O(4^k)
// https://kopricky.github.io/code/Academic/steiner_tree.html
int steiner_tree(const vector<vector<PI> > &g, const VI &term) {
  int n = g.size();
  int k = term.size();
  vector<vector<int> > dp(n, vector<int>(1 << k, inf));
  // base case: |bits| = 1
  REP(i, 0, k) {
    dp[term[i]][1 << i] = 0;
  }
  REP(bits, 1, 1 << k) {
    REP(i, 0, n) {
      REP(sub, 1, bits) {
        if ((sub & bits) != sub) continue;
        dp[i][bits] = min(dp[i][bits], dp[i][sub] + dp[i][bits - sub]);
      }
    }
    priority_queue<PI, vector<PI>, greater<PI> > que;
    REP(i, 0, n) {
      if (dp[i][bits] < inf) {
        que.push(PI(dp[i][bits], i));
        dp[i][bits] = inf;
      }
    }
    while (not que.empty()) {
      PI dv = que.top(); que.pop();
      int d = dv.first;
      int v = dv.second;
      if (dp[v][bits] <= d) continue;
      dp[v][bits] = d;
      REP(j, 0, g[v].size()) {
        PI wc = g[v][j];
        int w = wc.first;
        int c = wc.second;
        que.push(PI(d + c, w));
      }
    }
  }
  int mi = inf;
  REP(i, 0, n) {
    mi = min(mi, dp[i][(1 << k) - 1]);
  }
  return mi;   
}

int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w;
  while(cin >> h >> w && h && w) {
    vector<VI> s(h, VI(w));
    REP(i, 0, h) {
      REP(j, 0, w) {
        cin >> s[i][j];
      }
    }
    vector<vector<PI> > g(h * w);
    int dx[4] = {1, 0, -1, 0};
    int dy[4] = {0, 1, 0, -1};
    VI term;
    REP(i, 0, h) {
      REP(j, 0, w) {
        int v = i * w + j;
        if (s[i][j] == 1) term.push_back(v);
        REP(d, 0, 4) {
          int nx = i + dx[d];
          int ny = j + dy[d];
          if (nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
          int u = nx * w + ny;
          g[v].push_back(PI(u, 1));
        }
      }
    }
    cout << h * w - 1 - steiner_tree(g, term) << endl;
  }
}