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.