#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <fstream>
#include <bitset>
   
using namespace std;
   
 
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define rforeach(it, c) for (__typeof__((c).rbegin()) it=(c).rbegin(); it != (c).rend(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define CL(arr, val) memset(arr, val, sizeof(arr))
#define COPY(dest, src) memcpy(dest, src, sizeof(dest))
#define ten(n) ((long long)(1e##n))
#define bin(n) (1ull << (n))
#define erep(i, n) for (int i = 0; i <= (int)(n); ++i)
#define revrep(i, n) for (int i = (n); i >= 0; --i)
#define pb push_back

template <class T> void chmax(T& a, const T& b) { a = max(a, b); }
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }

template <class T> void uniq(T& c) { sort(c.begin(), c.end()); c.erase(unique(c.begin(), c.end()), c.end()); }
 
template <class T> string to_s(const T& a) { ostringstream os; os << a; return os.str(); }
template <class T> T to_T(const string& s) { istringstream is(s); T res; is >> res; return res; }
  
template <class T, class U> ostream& operator<<(ostream& os, pair<T, U>& p) { os << "( " << p.first << ", " << p.second << " )"; return os; }
  
template <class T> void print(T a, int n, const string& deli = " ", int br = 1) { for (int i = 0; i < n; ++i) { cout << a[i]; if (i + 1 != n) cout << deli; } while (br--) cout << endl; }
template <class T> void print(const T& c, const string& deli = " ", int br = 1) { foreach (it, c) { cout << *it; if (++it != c.end()) cout << deli;--it; } while (br--) cout << endl; }
template <class T> void print2d(T a, int w, int h, int width = -1, int br = 1) { for (int i = 0; i < h; ++i) { for (int j = 0; j < w; ++j) {    if (width != -1) cout.width(width); cout << a[i][j] << ' '; } cout << endl; } while (br--) cout << endl; }
   
template <class T> void input(T& a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }
template <class T> void input(T* a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }

void fix_pre(int n) { cout.setf(ios::fixed, ios::floatfield); cout.precision(10); }
void fast_io() { cin.tie(0); ios::sync_with_stdio(false); }
#define trace(x) (cout << #x << ": " << (x) << endl)
 
bool in_rect(int x, int y, int w, int h) { return 0 <= x && x < w && 0 <= y && y < h; }


typedef long long ll;
typedef pair<int, int> pint;
 
// y(v): v>^<  y(^): ^>v<
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };

const double PI = acos(-1.0);



class BipatiteGraph
{
    vector<bool> used;

    bool _dfs(int v)
    {
        used[v] = true;
        for (int i = 0; i < (int)edges[v].size(); ++i)
        {
            int u = edges[v][i];
            int k = match[u];
            if (k < 0 || (!used[k] && _dfs(k)))
            {
                match[v] = u;
                match[u] = v;
                return true;
            }
        }
        return false;
    }

public:
    int n, m;
    int vertices;
    vector<vector<int> > edges;
    vector<int> match;
    int matching;

    BipatiteGraph(int n, int m)
        : used(n + m), n(n), m(m), vertices(n + m), edges(n + m), match(n + m), matching(0)
    {
        clear();
    }

    void add_edge(int a, int b)
    {
        edges[a].push_back(b + n);
        edges[b + n].push_back(a);
    }

    void clear()
    {
        fill(match.begin(), match.end(), -1);
        matching = 0;
    }

    bool dfs(int v)
    {
        fill(used.begin(), used.end(), false);
        return _dfs(v);
    }

    int update_matching()
    {
        for (int i = 0; i < n; ++i)
            if (match[i] < 0 && dfs(i))
                ++matching;
        return matching;
    }

    int max_matching()
    {
        fill(match.begin(), match.end(), -1);
        int res = 0;
        for (int i = 0; i < n; ++i)
        {
            if (match[i] < 0)
            {
                if (dfs(i))
                    ++res;
            }
        }
        return res;
    }

    vector<pair<int, int> > matching_edges()
    {
        max_matching();
        vector<pair<int, int> > edges;
        for (int i = 0; i < n; ++i)
            if (match[i] >= 0)
                edges.push_back(make_pair(i, match[i] - n));
        return edges;
    }
};


int h, w;
char c[128][128];
bool is_L_vertex(int x, int y)
{
    int choco = 0;
    rep(i, 2) rep(j, 2)
        if (c[y + i][x + j] == '#')
            ++choco;
    return choco == 3;            
}

struct Cut
{
    int p, low, high; // (p, (low, high)) -> (y, (x1, x2)) or (x, (y1, y2))
};

Cut cut_hor(int x, int y)
{
    int tx = x;
    while (tx < w - 1 && c[y][tx + 1] == '#' && c[y + 1][tx + 1] == '#')
        ++tx;
    return (Cut){y, x, tx};
}
Cut cut_ver(int x, int y)
{
    int ty = y;
    while (ty < h - 1 && c[ty + 1][x] == '#' && c[ty + 1][x + 1] == '#')
        ++ty;
    return (Cut){x, y, ty};
}

bool intersect(const Cut& hor, const Cut& ver)
{
    return hor.low <= ver.p && ver.p <= hor.high
        && ver.low <= hor.p && hor.p <= ver.high;
}

int main()
{
    fast_io();

    while (cin >> h >> w, h)
    {
        rep(i, h)
            cin >> c[i];

        int L_vertices = 0;

        // カットの両端がL vertexであるカットを列挙
        static vector<Cut> hor_cut, ver_cut;
        hor_cut.clear(), ver_cut.clear();
        rep(y, h - 1) rep(x, w - 1)
        {
            if (is_L_vertex(x, y))
            {
                ++L_vertices;

                // カットの両端がL vertex？
                Cut hor = cut_hor(x, y);
                if (hor.low < hor.high && is_L_vertex(hor.high, y))
                    hor_cut.pb(hor);

                Cut ver = cut_ver(x, y);
                if (ver.low < ver.high && is_L_vertex(x, ver.high))
                    ver_cut.pb(ver);
            }
        }

        // 横カット <-> 縦カットの二部グラフ
        // カットが交わっていれば辺を張る
        BipatiteGraph g(hor_cut.size(), ver_cut.size());
        rep(i, hor_cut.size()) rep(j, ver_cut.size())
            if (intersect(hor_cut[i], ver_cut[j]))
                g.add_edge(i, j);

        int max_independent_set = (hor_cut.size() + ver_cut.size()) - g.max_matching();
        int pieces = L_vertices - max_independent_set + 1;
        cout << pieces << endl;
    }
}

Measured memory_bytes: 1556