#include<bits/stdc++.h>

using namespace std;


int p[10][10], s[10][10];
vector< vector< int > > st;
map< tuple< vector< vector< int > >, int, int >, int > dp;
int W, H;

int dfs(int x, int y)
{
  auto ps = tie(st, x, y);
  if(dp.count(ps)) return (dp[ps]);
  if(y == H) return (0);
  if(x == W) return (dfs(0, y + 1));
  if(p[y][x] == 0) return (dfs(x + 1, y));
  int ret = 1 << 30;
  if(st[y][x] == 0) ret = min(ret, dfs(x + 1, y));
  vector< pair< int, int > > beet;
  for(int i = 0; i < s[y][x]; i++) {
    for(int j = 0; j < s[y][x]; j++) {
      if(st[y + i][x + j] == 1) {
        beet.emplace_back(y + i, x + j);
        st[y + i][x + j] = 0;
      }
    }
  }
  if(beet.size()) {
    ret = min(ret, dfs(x + 1, y) + 1);
    for(auto &p : beet) st[p.first][p.second] = 1;
  }
  return (dp[ps] = ret);
}

int main()
{
  while(cin >> W >> H, W) {
    dp.clear();
    st.resize(H);
    for(int i = 0; i < H; i++) {
      st[i].resize(W);
      for(int j = 0; j < W; j++) {
        cin >> p[i][j];
        st[i][j] = p[i][j];
      }
    }
    for(int i = 0; i < H; i++) {
      for(int j = 0; j < W; j++) {
        for(int k = min(H - i, W - j); k >= 1; k--) {
          bool flag = true;
          for(int l = 0; l < k; l++) {
            for(int m = 0; m < k; m++) flag &= p[i + l][j + m];
          }
          if(flag) {
            s[i][j] = k;
            break;
          }
        }
      }
    }
    cout << dfs(0, 0) << endl;
  }
}