#include <bits/stdc++.h>
#define rep(i, a) for (ll i = 0; i < (a); ++i)
#define pb push_back
#define all(v) v.begin(),v.end()
#define sort_1(v) sort(v.begin(),v.end())
#define sort_2(v) sort(v.begin(),v.end(),greater<ll>())
#define reverse(v) reverse(v.begin(),v.end())
typedef long long ll;
typedef long double la;
using namespace std;

char f[102][102];
char c;

void dfs(int y, int x){
    if(f[y][x] != c)
        return;
    if(f[y][x] == '.')
        return;
    
    f[y][x] = '.';
    
    dfs(y-1, x);
    dfs(y, x+1);
    dfs(y+1, x);
    dfs(y, x-1);
}

int main(){
    while(1){
        int h,w;
        int cnt = 0;
        cin >> h >> w;
        if(h == 0 && w == 0){
            break;
        }
        for(int i = 1; i <= h; i++){
            for(int j = 1; j <= w; j++){
                cin >> f[i][j];
            }
        }
        for(int i = 1; i <= h; i++){
            for(int j = 1; j <= w; j++){
                if(f[i][j] != '.'){
                    c = f[i][j];
                    cnt++;
                    dfs(i, j);
                }
            }
        }
        cout << cnt << endl;
    }
}
