#include <bits/stdc++.h>

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define ALL(x) begin(x),end(x)

using namespace std;

class BipartiteMatching {
  int V;
  vector<vector<int>> g;
  vector<int> match;
  vector<bool> used;
  bool dfs(int v) {
    used[v] = true;
    for (int u: g[v]) {
      int w = match[u];
      if (w < 0 || (!used[w] && dfs(w))) {
        match[v] = u; match[u] = v;
        return true;
      }
    }
    return false;
  }
public:
  BipartiteMatching (int v) : V(v), g(v), match(v), used(v) {}
  void add_edge(int u, int v) {
    g[u].push_back(v);
    g[v].push_back(u);
  }
  int maximum_matching(void) {
    int res = 0;
    fill (ALL(match), -1);
    REP(v, V) {
      if (match[v] < 0) {
        fill (ALL(used), 0);
        if (dfs(v)) res++;
      }
    }
    return res;
  }
};

int main() {
  while(1){
    int h,w;
    cin>>h>>w;
    if(!h)break;
    vector<string> t(h);
    REP(i,h)cin>>t[i];
    int res = 1;
    vector<vector<int>> p(h-1,vector<int>(w-1, 0));
    REP(i,h-1)REP(j,w-1) {
      REP(k,2)REP(l,2) {
        if (t[i+k][j+l] == '#') ++p[i][j];
      }
      if (p[i][j] == 3) ++res;
    }
    using E = tuple<int, int, int>;
    vector<E> eh, ev;
    REP(i,h-1)REP(j,w-1) {
      if (p[i][j] == 3) {
        if (t[i][j] == '.' || t[i+1][j] == '.') {
          for (int k = j+1; k < w-1; ++k) {
            if (p[i][k] == 3) {
              eh.emplace_back(i, j, k);
            }
            if (p[i][k] < 4) break;
          }
        }
        if (t[i][j] == '.' || t[i][j+1] == '.') {
          for (int k = i+1; k < h-1; ++k) {
            if (p[k][j] == 3) {
              ev.emplace_back(i, j, k);
            }
            if (p[k][j] < 4) break;
          }
        }
      }
    }
    int n = eh.size() + ev.size();
    BipartiteMatching bm(n);
    REP(a, eh.size()) {
      int i,j,k;
      tie(i,j,k) = eh[a];
      REP(b, ev.size()) {
        int p,q,r;
        tie(p, q, r) = ev[b];
        if (p <= i && i <= r && j <= q && q <= k) {
          bm.add_edge(a, eh.size() + b);
        }
      }
    }
    res -= n - bm.maximum_matching();
    cout << res << endl;
  }
  return 0;
}