#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

const int dx[] = { -1, 0, 0, 1 }, dy[] = { 0, -1, 1, 0 };
//[const int dx[] = { -1, -1, -1, 0, 0, 1, 1, 1 }, dy[] = { 0, -1, 1, -1, 1, 0, -1, 1 };
bool valid(int x, int y, int h, int w) { return (x >= 0 && y >= 0 && x < h&&y < w); }
int place(int x, int y, int w) { return w*x + y; }

int w, h;
vector<vi> p, len, fld;
typedef tuple<vector<vi>, int, int> Data;
map<Data, int> mp;

bool check(int x,int y,int l)
{
	REP(i, l)REP(j, l)
	{
		int tx = x + i, ty = y + j;
		if (!valid(tx, ty, h, w)) return false;
		if (!p[tx][ty]) return false;
	}
	return true;
}

int dfs(int x, int y)
{
	Data tmp = make_tuple(fld, x, y);
	if (mp.count(tmp)) return mp[tmp];
	//if (mp.count(fld)) return mp[fld];
	int res = INF;
	if (y == w) res = dfs(x + 1, 0);
	else if (x == h) return 0;
	else if (!p[x][y]) res = dfs(x, y + 1);
	else if (!fld[x][y])
	{
		vector<pii> v;
		int l = len[x][y];
		REP(i, l)REP(j, l)
		{
			int tx = x + i, ty = y + j;
			if (!fld[tx][ty]) v.emplace_back(tx, ty);
		}
		if (v.size())
		{
			REP(i, v.size())
			{
				fld[v[i].first][v[i].second] = 1;
			}
			res = dfs(x, y + 1) + 1;
			REP(i, v.size())
			{
				fld[v[i].first][v[i].second] = 0;
			}
		}
	}
	else
	{
		chmin(res, dfs(x, y + 1));
		vector<pii> v;
		int l = len[x][y];
		REP(i, l)REP(j, l)
		{
			int tx = x + i, ty = y + j;
			if (!fld[tx][ty]) v.emplace_back(tx, ty);
		}
		if (v.size())
		{
			REP(i, v.size())
			{
				fld[v[i].first][v[i].second] = 1;
			}
			chmin(res, dfs(x, y + 1) + 1);
			REP(i, v.size())
			{
				fld[v[i].first][v[i].second] = 0;
			}
		}
	}
	//REP(i, h)
	//{
	//	REP(j, w) cout << fld[i][j] << " ";
	//	cout  << endl;
	//}
	return mp[tmp] = res;
	//return mp[fld] = res;
	//return res;
}

int main()
{
	cin.sync_with_stdio(false);
	while (cin >> w >> h, w)
	{
		p.clear(), len.clear(), fld.clear(), mp.clear();
		p.resize(h, vi(w)), len.resize(h, vi(w)), fld.resize(h, vi(w));
		REP(i,h)REP(j,w)
		{
			cin >> p[i][j];
			if (!p[i][j]) fld[i][j] = 1;
		}
		REP(i, h)REP(j, w)
		{
			if (!p[i][j]) continue;
			for (int k = min(h, w); k >= 0; k--)
			{
				if (check(i, j, k))
				{
					len[i][j] = k;
					break;
				}
			}
		}
		
		cout << dfs(0, 0) << endl;
	}
	return 0;
}