#include "bits/stdc++.h" using namespace std; typedef long long ll; typedef pair pii; #define rep(i,n) for(ll i=0;i<(ll)(n);i++) #define all(a) (a).begin(),(a).end() #define vi vector #define pb push_back #define INF 999999999 //#define INF (1LL<<59) int main(){ int h,w; cin>>h>>w; vector data(h); rep(i,h) cin>>data[i]; static int dp[3002][3002]; rep(i,3002)rep(j,3002)dp[i][j] = -1; rep(y,h)rep(x,w)if(data[y][x]=='.')dp[y][x] = 0; int ans = 0; rep(y,h){ rep(x,w){ if(data[y][x]=='.')continue; queue que; stack st; que.push(pii(y,x)); while(que.size()){ pii q = que.front(); que.pop(); st.push(q); dp[q.first][q.second]=INF; int dy[]={1,1,1,0,-1,-1,-1,0}; int dx[]={-1,0,1,1,1,0,-1,-1}; rep(i,8){ int ddy = q.first+dy[i], ddx = q.second+dx[i]; if(dp[ddy][ddx] == -1 && data[ddy][ddx] == '#'){ if( ddx>=0 && ddy>=0 && ddx=0 && ddy>=0 && ddx