#include <bits/stdc++.h>
using namespace std;

const int MAX = 100;
char mp[MAX][MAX+1];
int dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};

int H, W;

void dfs(int x, int y) {
    char pos = mp[x][y];
    mp[x][y] = '.';
    for (int i = 0; i < 4; i++)
    {
        int nx = x + dx[i];
        int ny = y + dy[i];
        if (0 <= nx && nx < H && 0 <= ny && ny < W && mp[nx][ny] == pos)
        {
            dfs(nx, ny);
        }
    }
}

int main(void) {
    while (cin >> H >> W) {
        if (H == 0 && W == 0)
            break;
        for (int i = 0; i < H; i++)
        {
            for (int j = 0; j < W; j++)
            {
                cin >> mp[j][i];
            }
        }

        int ans = 0;
        for (int i = 0; i < H; i++)
        {
            for (int j = 0; j < W; j++)
            {
                if (mp[j][i] != '.')
                {
                    dfs(j, i);
                    ans++;
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}
