#include <cstdio>

using namespace std;

char a[100][100];

bool fill(int h, int w, int x, int y) {
    if (a[x][y] == 'x') return false;
    char c = a[x][y];
    a[x][y] = 'x';
    if (x + 1 < w  && a[x + 1][y] == c) fill(h, w, x + 1, y);
    if (0 <= x - 1 && a[x - 1][y] == c) fill(h, w, x - 1, y);
    if (y + 1 < h  && a[x][y + 1] == c) fill(h, w, x, y + 1);
    if (0 <= y - 1 && a[x][y - 1] == c) fill(h, w, x, y - 1);
    return true;
}

int main(void) {
    int h, w;
    while (true) {
        scanf("%d %d", &h, &w);
        if (h == 0 && w == 0) break;
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                scanf(" %c", &a[j][i]);
            }
        }
        int n = 0;
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (fill(h, w, i, j)) n++;
            }
        }
        printf("%d\n", n);
    }
    return 0;
}