#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<string>
#include<queue>
using namespace std;
const int N=101;
const int xd[]={0,-1,0,1};
const int yd[]={-1,0,1,0};
struct node{
int x,y;
}now,top,nxt;
char a[N][N];
bool vis[N][N];
int answer;
int n,m;
queue<node>q;
inline int read()
{
int x=0;char c=getchar();
while(c<‘0‘||c>‘9‘)c=getchar();
return x=c-‘0‘;
}
inline void bfs(int x,int y)
{
answer++;
now.x=x;
now.y=y;
q.push(now);
vis[x][y]=1;
while(!q.empty())
{
top=q.front();
q.pop();
for(int i=0;i<4;i++)
{
int xx=xd[i]+top.x;
int yy=yd[i]+top.y;
if(a[xx][yy]&&xx>0&&xx<=n&&yy>0&&yy<=m)
{
a[xx][yy]=0;
nxt.x=xx;
nxt.y=yy;
q.push(nxt);
}
}
}
}
int main()
{
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
{
char c;
cin>>c;
if(c==‘#‘)a[i][j]=1;
else a[i][j]=0;
}
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
if(a[i][j])
bfs(i,j);
printf("%d",answer);
return 0;
}