#include <iostream>
#include <string>
int a[105][105];
bool tf[105][105];
int w , h;
int dirc[4][2] = {{-1 , 0} , {1 , 0} , {0 , -1} , {0 , 1}};
void dfs(int x , int y){
    tf[y][x] = true;
    for(int i = 0;i < 4;i++){
        int nx = x + dirc[i][0] , ny = y + dirc[i][1];
        if(nx >= 0 && nx < w && ny >= 0 && ny < h && tf[ny][nx] == false && a[ny][nx] == a[y][x]){
            dfs(nx , ny);
        }
    }
}
int main(){
    while(std::cin >> h >> w){
        if(h == 0 && w == 0){
            break;
        }
        std::string s;
        for(int i = 0;i < h;i++){
            std::cin >> s;
            for(int j = 0;j < w;j++){
                a[i][j] = (s[j] == '#')? 1 :
                          (s[j] == '*')? 2 : 3; 
                tf[i][j] = false;
            }
        }
        int ans = 0;
        for(int i = 0;i < h;i++){
            for(int j = 0;j < w;j++){
                if(tf[i][j] == false){
                    ans++;
                    dfs(j , i);
                }
            }
        }
        std::cout << ans << "\n";
    }
}
