#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>

using namespace std;

char m[102][102];
int w, h;

void dfs(char s, int x, int y) {
    if (m[x][y] == s) {
        m[x][y] = '!';
        dfs(s, x + 1, y);
        dfs(s, x - 1, y);
        dfs(s, x, y + 1);
        dfs(s, x, y - 1);
    }
}

bool solve() {
    cin >> h >> w;
    if (w == 0 && h == 0) {
        return false;
    }
    string temp;
    for (int i = 0; i < 102; i++) {
        for (int j = 0; j < 102; j++)
            m[i][j] = '!';
    }
    for (int i = 0; i < h; i++) {
        cin >> temp;
        for (int j = 0; j < w; j++) {
            m[j + 1][i + 1] = temp[j];
        }
    }
    int count = 0;
    for (int x = 1; x <= w; x++) {
        for (int y = 1; y <= h; y++) {
            if (m[x][y] != '!') {
                count++;
                dfs(m[x][y], x, y);
            }
        }
    }
    cout << count << endl;
    return true;
}

int main(void) {
    while (solve());
}
