#include <iostream>
#include <vector>
#include <queue>

using namespace std;
int main()
{
int a,b;
cin>>a>>b;
char mat[a][b];
bool v[a][b];
for(int i=0;i<a;i++)
{
for(int j=0;j<b;j++)
{
cin>>mat[i][j];
v[i][j]=false;
}
}
int k=0;
for(int i=0;i<a;i++)
{
for(int j=0;j<b;j++)
{
if(mat[i][j]=='+' && v[i][j]!=true)
{
queue<int>Q;
Q.push(i);
Q.push(j);
while(!Q.empty())
{
int ci=Q.front();
Q.pop();
int cj=Q.front();
Q.pop();
if(ci+1<a && mat[ci+1][cj]!='-' && v[ci+1][cj]==false)
{
Q.push(ci+1);
Q.push(cj);
v[ci+1][cj]=true;
}
if(ci-1>=0 && mat[ci-1][cj]!='-' && v[ci-1][cj]==false)
{
Q.push(ci-1);
Q.push(cj);
v[ci-1][cj]=true;
}
if(cj+1<b && mat[ci][cj+1]!='-' && v[ci][cj+1]==false)
{
Q.push(ci);
Q.push(cj+1);
v[ci][cj+1]=true;
}
if(cj-1>=0 && mat[ci][cj-1]!='-' && v[ci][cj-1]==false)
{
Q.push(ci);
Q.push(cj-1);
v[ci][cj-1]=true;
}
}
k++;
}
}
}
cout<<k;
return 0;
}
