#include <iostream>
#include <stack>
#include <queue>

using namespace std;

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

typedef pair<int, int> P;

int main()
{
    int H,W;
    while(cin >> H >> W && H) {
        char field[H][W];
        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] != ' ') {
                    ans++;
                    char c = field[i][j];
                    queue<P> que;
                    que.push(P(j, i));
                    while(!que.empty()) {
                        P p = que.front(); que.pop();
                        int x = p.first, y = p.second;
                        if(x >= 0 && x < W && y >= 0 && y < H && field[y][x] == c) {
                            field[y][x] = ' ';
                            for(int k = 0; k < 4; k++) que.push(P(x + dx[k], y + dy[k]));
                        }
                    }
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}