#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <map>
#include <vector>
#include <queue>
#define LL long long
#define PII pair<int, int>
using namespace std;
const int MAXN = 100;

int W, H;
int dirx[] = {1, 0, -1, 0}, diry[4] = {0, 1, 0, -1};
char fruit[MAXN+5][MAXN+5];

void dfs(int r, int c) {
    char ch = fruit[r][c];
    fruit[r][c] = '\0';
    for (int i = 0; i < 4; i++) {
        int nr = r + diry[i], nc = c + dirx[i];
        if (nr < 0 || nr >= H) continue;
        if (nc < 0 || nc >= W) continue;
        if (fruit[nr][nc] != ch) continue;
        dfs(nr, nc);
    }
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    while (cin >> H >> W) {
        if (!W and !H) break;
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                cin >> fruit[i][j];
            }
        }

        int ans = 0;
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (fruit[i][j] != '\0') {
                    ans++;
                    dfs(i, j);
                }
            }
        }

        cout << ans << "\n";
    }
}

