#include <iostream>

#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

using namespace std;

const int MAX_W = 100, MAX_H = 100;
const int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};
char field[100][100];

void rec(int x, int y, char c)
{
    if(field[y][x] == c) {
        field[y][x] = 'x';
        for(int i = 0; i < 4; i++) 
            rec(x + dx[i], y + dy[i], c);
    }
}

int main()
{
    int H,W;
    while(cin >> H >> W && H) {
        for(int i = 0; i < H; i++) 
            for(int j = 0; j < W; j++) 
                cin >> field[i][j];
        
        int ans = 0;
        for(int i = 0; i < H; i++) {
            for(int j = 0; j < W; j++) {
                if(field[i][j] != 'x') {
                    ans++;
                    rec(j, i, field[i][j]);
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}