#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

#pragma GCC target("avx,avx2")
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ll=long long ;
#define Whats(x) //cout<<#x<<" is "<<(x)<<endl


////フォード - ファルカーソン法 O(Flow|E|)

typedef int Weight;

const Weight INF = 1e9;
const Weight ZERO = 0;
struct Edge {
	int src, dst;
	Weight weight;
	int rev;
	int id;
	Edge(int src_, int dst_, Weight weight_, const int rev_, const int id_) :
		src(src_), dst(dst_), weight(weight_), rev(rev_), id(id_) { }
	Edge(int src_, int dst_, Weight weight_, const int rev_) :
		src(src_), dst(dst_), weight(weight_), rev(rev_) { }
	Edge() :src(0), dst(0), weight(0) {
	}
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;
void add_edge(Graph&g, int from, int to, int cap)
{
	g[from].push_back(Edge(from, to, cap, (int)g[to].size()));
	g[to].push_back(Edge(to, from, 0, (int)g[from].size() - 1));
}
//二つを繋ぐ線を完全に消す
void erase_edge(Graph&g, const  int from, const int to) {
	g[from].erase(remove_if(g[from].begin(), g[from].end(), [=](const Edge&e) {return e.dst == to; }), g[from].end());
	g[to].erase(remove_if(g[to].begin(), g[to].end(), [=](const Edge&e) {return e.dst == from; }), g[to].end());
}
int dfs(vector<int>&used, Graph&g, int now, int t, int f)
{
	if (now == t) {
		return f;
	}
	used[now] = true;
	for (int i = 0; i<g[now].size(); ++i) {
		Edge &e = g[now][i];
		if (!used[e.dst] && e.weight>0) {
			int d = dfs(used, g, e.dst, t, min(f, e.weight));
			if (d > 0) {
				e.weight -= d;
				g[e.dst][e.rev].weight += d;
				return d;
			}
		}
	}
	return 0;
}
Weight fold_falc(Graph g, const int start, const int goal) {
	Weight ans = 0;
	while (1) {
		vector<int>used(g.size());
		int flow = dfs(used, g, start, goal, INF);
		if (!flow)return ans;
		else ans += flow;
	}
}
struct line {
	int l;
	int u;
	int r;
	int d;
};
int main() {
	while (true) {
		int H,W;cin>>H>>W;
		if(!H)break;
		vector<string>field(H);
		for(int i=0;i<H;++i)cin>>field[i];

		vector<vector<int>>nums(H+1,vector<int>(W+1));
		for (int y = 0; y < H - 1; ++y) {
			for (int x = 0; x < W - 1; ++x) {
				for (int dx = 0; dx < 2; ++dx) {
					for (int dy = 0; dy < 2; ++dy) {
						nums[y+1][x+1]+=field[y+dy][x+dx]=='#';
					}
				}
			}
		}
		vector<pair<int,int>>points;
		for (int j = 1; j <= W; ++j) {
			for (int i = 1; i <= H; ++i) {

				if(nums[i][j]==3)points.push_back(make_pair(j,i));
			}
		}
		vector<line>x_lines,y_lines;
		for (int i = 0; i < points.size(); ++i) {
			for (int j = i+1; j < points.size(); ++j) {
				int l=points[i].first,r=points[j].first;
				int u=points[i].second,d=points[j].second;
				if(l==r){
					int x=l;
					bool ok=true;
					for (int y = u; y < d; ++y) {
						if(field[y][x-1]=='.')ok=false;
						if(field[y][x]=='.')ok=false;
					}
					if (ok) {
						y_lines.push_back(line{ l,u,r,d });
					}
				}
				if(u==d){
					int y=u;
					
					bool ok = true;
					for (int x = l; x < r; ++x) {
						if(field[y][x]=='.')ok=false;
						if(field[y-1][x]=='.')ok=false;
					}
					if (ok) {
						x_lines.push_back(line{ l,u,r,d });
					}
				}
			}
		}
		const int start=0;
		const int xl=start+1;
		const int yl=xl+x_lines.size();
		const int goal=yl+y_lines.size();
		Graph g(goal+1);
		for (int i = 0; i < x_lines.size(); ++i) {
			for (int j = 0; j < y_lines.size(); ++j) {
				auto axl=x_lines[i];
				auto ayl=y_lines[j];
				bool ok=true;
				//Whats(axl.l);Whats(axl.r);
			
				if (axl.l <= ayl.l&&ayl.l <= axl.r) {
					if (ayl.u <= axl.u&&axl.u <= ayl.d) {
						ok=false;
						//cout<<"ng"<<endl;
					}
				}
				if (!ok) {
					add_edge(g,xl+i,yl+j,10000);
				}
			}
		}
		for (int i = 0; i < x_lines.size(); ++i) {
			add_edge(g,start,xl+i,1);
			add_edge(g,xl+i,goal,0);
		}
		for (int i = 0; i < y_lines.size(); ++i) {
			add_edge(g,start,yl+i,0);
			add_edge(g,yl+i,goal,1);
		}
		int flow=fold_falc(g,start,goal);
		Whats(points.size());
		Whats(x_lines.size());
		Whats(y_lines.size());
		Whats(flow);
		int answer=1+points.size()-x_lines.size()-y_lines.size()+flow;
		cout<<answer<<endl;
	}
	return 0;
}
