//C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#define rp(i,a,b) for(int (i)=(int)(a);i<(int)(b);++i)
using namespace std;
char l[101][101];
int xx,yy,ans=0;
int movex[]={0,0,1,-1},movey[]={1,-1,0,0};
void dfs(int sx,int sy,char c){
    l[sx][sy]='n';
    for(int i=0;i<4;i++){
        int x=sx+movex[i],y=sy+movey[i];
        if(0<=x and x<xx and 0<=y and y<yy){
            if(c==l[x][y]) dfs(x,y,c);
        }
    }
}
int main(){

    while(1){
        int a,b;
        cin>>a>>b;
        xx=a;
        yy=b;
        if(a==0 and b==0) break;
        for(int i=0;i<a;i++){
            for(int j=0;j<b;j++){
                cin>>l[i][j];
            }
        }
        for(int i=0;i<a;i++){
            for(int j=0;j<b;j++){
                if(l[i][j]!='n') {dfs(i,j,l[i][j]);ans++;}
                
            }
        }
        cout<<ans<<endl;
        ans=0;

    }
}