#include <bits/stdc++.h>
using namespace std;
int ans,n,m;
string a[110];
int dx[5]={-1,1,0,0};
int dy[5]={0,0,-1,1};
void dfs(int x,int y){
a[x][y]='0';
int fx,fy;
for(int i=0;i<=3;i++){
fx=x+dx[i];
fy=y+dy[i];
if(fx>=0&&fx<n&&fy>=0&&fy<m&&a[fx][fy] > '0'){
dfs(fx,fy);
}
}
return ;
}
int main(){
scanf("%d%d",&n,&m);
for (int i = 0; i < n; i++){
cin >> a[i];
}
for (int i = 0; i < n; i++){
for (int j = 0; j < m; j++){
if (a[i][j] > '0'){
dfs(i,j);
ans++;
}
}
}
printf("%d",ans);
return 0;
}
RP++
RP++
RP++
RP++
https://www.luogu.com.cn/paste/tah77ok9
111001111011110110010111111001001011110010011111111001101011011010011011
https://acm.hdu.edu.cn/
杭电网址https://www.luogu.com.cn/article/7lborgqn