#include <iostream>
#include <string>

using namespace std;

const int dx[] = {0, 1, 0, -1};
const int dy[] = {-1, 0, 1, 0};
int w, h;
int div;
string map[100];

void dfs(int x, int y, char c) 
{
    map[y][x] = '-';

    for (int i = 0; i < 4; i++) {
        int nx = x + dx[i];
        int ny = y + dy[i];

        if (nx < 0 || ny < 0 || nx >= w || ny >= h) 
            continue;
        else if (c == map[ny][nx])
            dfs(nx, ny, c);
    }
}

int main()
{
    while (cin >> h >> w, h || w) {
        for (int y = 0; y < h; y++)
            cin >> map[y];

        div = 0; 
        for (int y = 0; y < h; y++) 
            for (int x = 0; x < w; x++) {
                char ch = map[y][x];
                if (ch == '#' || ch == '*' || ch == '@') {
                    dfs(x, y, ch);
                    div++;
                }
            }

        cout << div << endl;
    }

    return 0;
}