1 #include<iostream>
2 #include<cstring>
3 #include<cstdio>
4 #define N 105
5 using namespace std;
6 int n,m,a[N][N],ans,dx[]={0,0,1,-1},dy[]={1,-1,0,0};
7 void dfs(int x,int y){
8 a[x][y]=0;
9 for(int i=0;i<4;i++){
10 int xx=x+dx[i],yy=y+dy[i];
11 if(a[xx][yy]==1) dfs(xx,yy);
12 }
13 }
14 int main()
15 {
16 char c;
17 memset(a,0,sizeof(a));
18 scanf("%d%d",&n,&m);
19 for(int i=1;i<=n;i++){
20 for(int j=1;j<=m;j++){
21 cin>>c;
22 if(c=='#') a[i][j]=1;
23 if(c=='.') a[i][j]=0;
24 }
25 }
26 for(int i=1;i<=n;i++){
27 for(int j=1;j<=m;j++){
28 if(a[i][j]==1) dfs(i,j),ans++;
29 }
30 }
31 printf("%d",ans);
32 return 0;
33 }