#include <iostream>
#include <stack>

#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};

typedef pair<int, int> P;

int main()
{
    int H,W;
    while(cin >> W >> H && 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];
                    stack<P> stk;
                    stk.push(P(j, i));
                    while(!stk.empty()) {
                        P p = stk.top(); stk.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++) stk.push(P(x + dx[k], y + dy[k]));
                            }
                            }
                    }
                }
                cout << ans << endl;
            }
            return 0;
        }
    }
    