#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <iterator>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) container.begin(), container.end()
#define RALL(container) container.rbegin(), container.rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int w, h, d[12][12], ans;

void solve(int x, int y, int c){
	if(ans <= c) return;
	if(17 < ans && ans < INF) return;
	if(x == w && y == h-1){
		chmin(ans, c);
		return ;
	}
	if(x == w){
		y ++;
		x = 0;
	}
	if(d[y][x] != 1) solve(x+1, y, c);
	if(ans <= c) return;
	if(17 < ans && ans < INF) return;
	if(d[y][x] != 0){
		int r = 1;
		for(;;r++){
			int f = 1;
			REP(i, r)REP(j, r) if(d[y+i][x+j] == 0) f = 0;
			if(!f) break;
		}
		r --;
		
		// check pruning
		int pos[3][2] = {{y-1,x-1},{y-1,x},{y,x-1}};
		REP(k, 3){
			if(pos[k][0] < 0 || pos[k][1] < 0) continue;
			int f = 1;
			REP(i, r+1)REP(j, r+1) if(d[pos[k][0]+i][pos[k][1]+j] == 0) f = 0;
			if(f) return;
		}
		vector<pii> ch;
		REP(i, r)REP(j, r){
			if(d[y+i][x+j] == 1) ch.push_back(pii(y+i, x+j));
			d[y+i][x+j] = -1;
		}
		if(ch.empty()) return ;
		solve(x+1, y, c+1);
		REP(i, ch.size()) d[ch[i].first][ch[i].second] = 1;
	}
	
}
int main(){
	ios::sync_with_stdio(false);
	while(cin >> w >> h, w){
		memset(d, 0, sizeof(d));
		REP(i, h)REP(j, w) cin >> d[i][j];
		ans = INF;
		solve(0, 0, 0);
		cout << ans << endl;
	}
	return 0;
}