#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 REPS(i,x) for(int i=1;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<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

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

bool bipartite_matching_dfs(
	int v, const vector< vector<int> > &conn,
	vector<bool> &used, vector<int> &match)
{
	used[v] = true;
	for(int i = 0; i < conn[v].size(); ++i){
		int u = conn[v][i], w = match[u];
		if(w < 0 || (!used[w] && bipartite_matching_dfs(w, conn, used, match))){
			match[v] = u;
			match[u] = v;
			return true;
		}
	}
	return false;
}
//O(E√V)
int bipartite_matching(const vector< vector<int> > &conn){
	int res = 0;
	vector<int> match(conn.size(), -1);
	vector<bool> used(conn.size(), false);
	for(int v = 0; v < conn.size(); ++v){
		if(match[v] < 0){
			fill(used.begin(), used.end(), false);
			if(bipartite_matching_dfs(v, conn, used, match)){ ++res; }
		}
	}
	return res;
}

int h, w;
int d[105][105];


typedef pair<pii, pii> Seg;
#define sx first.first
#define sy first.second
#define tx second.first
#define ty second.second

inline int count(int i, int j){
	return d[i][j]+d[i+1][j]+d[i][j+1]+d[i+1][j+1];
}

inline Seg seg(int y, int x, pii d){
	Seg res(pii(x, y), pii(x, y) + d);
	while(count(res.ty, res.tx) == 4) res.second = res.second + d;
	if(res.sy*1000+res.sx > res.ty*1000+res.tx) swap(res.first, res.second);
	return res;
}

inline bool intersect(Seg a, Seg b){
    return a.sx <= b.sx && b.sx <= a.tx && b.sy <= a.sy && a.sy <= b.ty;
}

int main(){
	ios::sync_with_stdio(false);
	while(cin >> h >> w, h){
		memset(d, 0, sizeof(d));
		REPS(i, h)REPS(j, w){
			char c;
			cin >> c;
			d[i][j] = c == '#';
		}
		vector<Seg> hol, ver;
		int ans = 0;
		REPS(i, h)REPS(j, w){
			if(count(i, j) != 3) continue;
			ans ++;
			if(d[i][j]&&d[i+1][j]) hol.push_back(seg(i, j, pii(-1, 0)));
			if(d[i][j]&&d[i][j+1]) ver.push_back(seg(i, j, pii(0, -1)));
			if(d[i][j+1]&&d[i+1][j+1]) hol.push_back(seg(i, j, pii(1, 0)));
			if(d[i+1][j]&&d[i+1][j+1]) ver.push_back(seg(i, j, pii(0, 1)));
		}
		sort(ALL(hol));
		REP(i, hol.size()) if(i+1==hol.size() || hol[i]!=hol[i+1]) hol.erase(hol.begin()+i--);
		sort(ALL(ver));
		REP(i, ver.size()) if(i+1==ver.size() || ver[i]!=ver[i+1]) ver.erase(ver.begin()+i--);
		int n = hol.size(), m = ver.size();
		vector<vi> g(n+m);
		REP(i, n)REP(j, m)if(intersect(hol[i], ver[j])){
			g[i].push_back(n+j);
			g[n+j].push_back(i);
		}
		cout << 1 + ans - (n+m - bipartite_matching(g)) << endl;
	}
	return 0;
}

Measured memory_bytes: 1620