#include <cstdio>
#include <queue>
using namespace std;

int main()
{
const int dx[] = {0, -1, 1, 0}, dy[] = {-1, 0, 0, 1};
while(true) {
int h, w;
char fld[128][128];
scanf("%d%d", &h, &w);
if(h == 0)
break;
for(int i = 0; i < h; ++i)
scanf("%s", fld[i]);
int ans = 0;
for(int sx = 0; sx < h; ++sx) {
for(int sy = 0; sy < w; ++sy) {
if(fld[sx][sy] == 'x')
continue;
char c = fld[sx][sy];
queue<pair<int, int> > q;
q.push(make_pair(sx, sy));
while(!q.empty()) {
int x = q.front().first, y = q.front().second;
q.pop();
for(int i = 0; i < 4; ++i) {
int nx = x + dx[i], ny = y + dy[i];
if(nx < 0 || ny < 0 || nx >= h || ny >= w)
continue;
if(fld[nx][ny] != c)
continue;
fld[nx][ny] = 'x';
q.push(make_pair(nx, ny));
}
}
ans += 1;
}
}
printf("%d\n", ans);
}
return 0;
}