#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

struct MaximumFlow {
    typedef int Index;
    typedef int Flow;
    static const Flow InfCapacity = 100000;
    struct Edge {
        Index to;
        Flow capacity;
        Index rev;
    };
    vector<vector<Edge> > g;
    void init(Index n) { g.assign(n, vector<Edge>()); }
    void add(Index i, Index j, Flow capacity) {
        Edge e, f; e.to = j, f.to = i; e.capacity = capacity, f.capacity = 0;
        g[i].push_back(e); g[j].push_back(f);
        g[i].back().rev = (Index)g[j].size() - 1; g[j].back().rev = (Index)g[i].size() - 1;
    }
    void addB(Index i, Index j, Flow capacity) {
        Edge e, f; e.to = j, f.to = i; e.capacity = capacity, f.capacity = capacity;
        g[i].push_back(e); g[j].push_back(f);
        g[i].back().rev = (Index)g[j].size() - 1; g[j].back().rev = (Index)g[i].size() - 1;
    }
    //g?????´?£???????
    Flow maximumFlow(int s, int t) {
        int n = g.size();
        vector<Index> level(n);
        Flow total = 0; bool update;
        do {
            update = false;
            fill(level.begin(), level.end(), -1); level[s] = 0;
            queue<Index> q; q.push(s);
            for(Index d = n; !q.empty() && level[q.front()] < d; ) {
                int u = q.front(); q.pop();
                if(u == t) d = level[u];
                for (Edge e: g[u]) if(e.capacity > 0 && level[e.to] == -1)
                    q.push(e.to), level[e.to] = level[u] + 1;
            }
            vector<Index> iter(n);
            for(Index i = 0; i < n; i ++) iter[i] = (int)g[i].size() - 1;
            while(1) {
                Flow f = augment(level, iter, s, t, InfCapacity);
                if(f == 0) break;
                total += f; update = true;
            }
        }while(update);
        return total;
    }
    Flow augment(vector<Index> &level, vector<Index> &iter, Index u, Index t, Flow f) {
        if(u == t || f == 0) return f;
        Index lv = level[u];
        if(lv == -1) return 0;
        level[u] = -1;
        for(; iter[u] >= 0; -- iter[u]) {
            Edge &e = g[u][iter[u]];
            if(level[e.to] <= lv) continue;
            Flow l = augment(level, iter, e.to, t, min(f, e.capacity));
            if(l == 0) continue;
            e.capacity -= l; g[e.to][e.rev].capacity += l;
            level[u] = lv;
            return l;
        }
        return 0;
    }
};

int main() {
	for (;;) {
		int H, W; cin >> H >> W;
		if (!H && !W) break;
		vector<vector<bool> > a(H + 2, vector<bool>(W + 2));
		for (int y = 1; y <= H; y++) {
			string s; cin >> s;
			for (int x = 1; x <= W; x++)
				a[y][x] = (s[x - 1] == '#');
		}
		H += 2; W += 2;
		vector<vector<int > > b(H, vector<int>(W));
		for (int y = 1; y <= H - 1; y++)
			for (int x = 1; x <= W - 1; x++)
				b[y][x] = a[y - 1][x - 1] + a[y - 1][x] + a[y][x - 1] + a[y][x];
		int ans = 1, N = 0, M = 0;
		vector<vector<vector<int> > > unko(H, vector<vector<int> >(W));
		for (int y = 1; y <= H - 1; y++)
			for (int x = 1; x <= W - 1; x++) {
				if (b[y][x] != 3) continue;
				ans++;
				if (a[y][x - 1] && a[y][x]) {
					int _y;
					for (_y = y + 1; b[_y][x] == 4; _y++);
					if (b[_y][x] != 3) continue;
					for (int z = y; z <= _y; z++)
						unko[z][x].push_back(N);
					N++;
				}
			}
		for (int y = 1; y <= H - 1; y++)
			for (int x = 1; x <= W - 1; x++) {
				if (b[y][x] != 3) continue;
				if (a[y - 1][x] && a[y][x]) {
					int _x;
					for (_x = x + 1; b[y][_x] == 4; _x++);
					if (b[y][_x] != 3) continue;
					for (int z = x; z <= _x; z++)
						unko[y][z].push_back(M);
					M++;
				}
			}
		MaximumFlow mf;
		mf.init(N + M + 2);
		int s = N + M, t = N + M + 1;
		for (int u = 0; u < N; u++)
			mf.add(s, u, 1);
		for (int v = 0; v < M; v++)
			mf.add(N + v, t, 1);
		for (int y = 1; y <= H - 1; y++)
			for (int x = 1; x <= W - 1; x++) {
				if (unko[y][x].size() != 2) continue;
				int u = unko[y][x][0], v = unko[y][x][1];
				mf.add(u, N + v, 100000);
			}
		cout << ans - N - M + mf.maximumFlow(s, t) << endl;
	}
}

Measured memory_bytes: 3908