#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct BiMatch{
  int n,time;
  vector<vector<int>> G;
  vector<int> match,used,dead;

  BiMatch(){}
  BiMatch(int n):n(n),time(0),G(n),
                 match(n,-1),used(n,-1),dead(n,0){}

  void add_edge(int u,int v){
    G[u].emplace_back(v);
    G[v].emplace_back(u);
  }

  int dfs(int v){
    used[v]=time;
    for(int u:G[v]){
      if(dead[u]) continue;
      int w=match[u];
      if((w<0)||(used[w]<time&&dfs(w))){
        match[v]=u;
        match[u]=v;
        return 1;
      }
    }
    return 0;
  }

  int build(){
    int res=0;
    for(int v=0;v<n;v++){
      if(dead[v]) continue;
      if(match[v]<0){
        time++;
        res+=dfs(v);
      }
    }
    return res;
  }

  int disable(int v){
    assert(!dead[v]);
    int u=match[v];
    if(~u) match[u]=-1;
    match[v]=-1;
    dead[v]=1;
    time++;
    return ~u?dfs(u)-1:0;
  }

  int enable(int v){
    assert(dead[v]);
    dead[v]=0;
    time++;
    return dfs(v);
  }
};

//INSERT ABOVE HERE
signed main(){
  int h,w;
  while(cin>>h>>w,h){
    vector<string> st(h);
    for(int i=0;i<h;i++) cin>>st[i];
    using P = pair<int, int>;
    vector<P> vp;
    map<P, int> idx;

    vector<vector<int>> tp(h,vector<int>(w,-1));
    for(int i=0;i+1<h;i++){
      for(int j=0;j+1<w;j++){
        int num=0;
        for(int a=0;a<2;a++)
          for(int b=0;b<2;b++)
            num+=st[i+a][j+b]=='#';

        if(num==3){
          if(st[i+0][j+0]=='.') tp[i][j]=0;
          if(st[i+0][j+1]=='.') tp[i][j]=1;
          if(st[i+1][j+0]=='.') tp[i][j]=2;
          if(st[i+1][j+1]=='.') tp[i][j]=3;

          idx[P(i,j)]=vp.size();
          vp.emplace_back(i,j);
        }
      }
    }

    int n=vp.size();
    using P = pair<int, int>;
    vector<P> es;

    for(int i=0;i+1<h;i++){
      for(int j=0;j+1<w;j++){
        if(tp[i][j]<0) continue;
        if(tp[i][j]<2){
          for(int k=i+1;k+1<h;k++){
            if(tp[k][j]<0){
              if(st[k][j+0]=='#'&&st[k][j+1]=='#') continue;
              break;
            }
            if(tp[k][j]>=2)
              es.emplace_back(idx[P(i,j)],idx[P(k,j)]);
            break;
          }
        }
        if(tp[i][j]%2==0){
          for(int l=j+1;l+1<w;l++){
            if(tp[i][l]<0){
              if(st[i+0][l]=='#'&&st[i+1][l]=='#') continue;
              break;
            }
            if(tp[i][l]%2==1)
              es.emplace_back(idx[P(i,j)],idx[P(i,l)]);
            break;
          }
        }
      }
    }

    #define F first
    #define S second
    int m=es.size();
    BiMatch G(m);
    for(int i=0;i<m;i++){
      for(int j=0;j<m;j++){
        if(vp[es[i].F].F!=vp[es[i].S].F) continue;
        if(vp[es[j].F].S!=vp[es[j].S].S) continue;
        if(vp[es[j].F].S< vp[es[i].F].S) continue;
        if(vp[es[j].F].S> vp[es[i].S].S) continue;
        if(vp[es[i].F].F< vp[es[j].F].F) continue;
        if(vp[es[i].F].F> vp[es[j].S].F) continue;
        G.add_edge(i,j);
        // cout<<i<<" "<<j<<endl;
      }
    }

    cout<<n-(m-G.build())+1<<endl;
  }
  return 0;
}



Measured memory_bytes: 3700