const maxr = 100;
var r,c,i,j:byte;
dem: word;
a: array[0..maxr,0..maxr+1] of char;
visit: array[0..maxr+1,0..maxr+1] of boolean;
procedure dfs(i,j:longint);
begin
visit[i,j]:=true;
if (i>1) and (a[i-1,j]='#') and (not visit[i-1,j]) then dfs(i-1,j);
if (i<r) and (a[i+1,j]='#') and (not visit[i+1,j]) then dfs(i+1,j);
if (j>1) and (a[i,j-1]='#') and (not visit[i,j-1]) then dfs(i,j-1);
if (j<c) and (a[i,j+1]='#') and (not visit[i,j+1]) then dfs(i,j+1);
end;
begin
readln(r,c);
for i:=1 to r do
for j:=1 to c do
visit[i,j]:=false;
for i:=1 to r do
begin
for j:=1 to c do
read(a[i,j]);
readln;
end;
dem:=0;
for i:=1 to r do
for j:=1 to c do
if (a[i,j]='#') and (not visit[i,j]) then
begin
inc(dem);
dfs(i,j);
end;
writeln(dem);
end.
Y29uc3QgbWF4ciA9IDEwMDsKdmFyIHIsYyxpLGo6Ynl0ZTsKICAgIGRlbTogd29yZDsKICAgIGE6IGFycmF5WzAuLm1heHIsMC4ubWF4cisxXSBvZiBjaGFyOwogICAgdmlzaXQ6IGFycmF5WzAuLm1heHIrMSwwLi5tYXhyKzFdIG9mIGJvb2xlYW47CnByb2NlZHVyZSBkZnMoaSxqOmxvbmdpbnQpOwpiZWdpbgogIHZpc2l0W2ksal06PXRydWU7CiAgaWYgKGk+MSkgYW5kIChhW2ktMSxqXT0nIycpIGFuZCAobm90IHZpc2l0W2ktMSxqXSkgdGhlbiBkZnMoaS0xLGopOwogIGlmIChpPHIpIGFuZCAoYVtpKzEsal09JyMnKSBhbmQgKG5vdCB2aXNpdFtpKzEsal0pIHRoZW4gZGZzKGkrMSxqKTsKICBpZiAoaj4xKSBhbmQgKGFbaSxqLTFdPScjJykgYW5kIChub3QgdmlzaXRbaSxqLTFdKSB0aGVuIGRmcyhpLGotMSk7CiAgaWYgKGo8YykgYW5kIChhW2ksaisxXT0nIycpIGFuZCAobm90IHZpc2l0W2ksaisx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