#include <bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int i=0;i<(int)(n);i++)

int dx[] = {1,0,-1,0}, dy[] = {0,1,0,-1};
int w, h;
char f[102][102];

bool ng(int x, int y) {
    return (x<0 or y<0 or x>=w or y>=h);
}

void dfs(int x, int y) {
    char c = f[y][x];
    f[y][x] = '.';
    rep(i,4) {
        int nx = x + dx[i];
        int ny = y + dy[i];
        if(!ng(nx,ny) and f[ny][nx] == c) dfs(nx,ny);
    }
    return ;
}

int main() {
    while(cin>>w>>h and w) {
        rep(y,h) rep(x,w) cin >> f[y][x];
        
        int ans = 0;
        rep(y,h) rep(x,w) {
            if(f[y][x] == '.') continue;
            ans++;
            dfs(x, y);
        }

        cout << ans << endl;
    }
    
    return 0;
}