#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=(0);(i)<(int)(n);++(i))
using ll = long long;
using P = pair<int, int>;
using namespace std;

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int n, m;
char rc[101][101];

int dx[] = { 0, 1, 0, -1 };
int dy[] = { 1, 0, -1, 0 };

bool ok(int r, int c) {
    return 0 <= r and r < n and 0 <= c and c < m;
}

void dfs(int y, int x, char ch) {
    rep(d, 4) {
        int ny = y + dy[d], nx = x + dx[d];
        if (ok(ny, nx) and rc[ny][nx] == ch) {
            rc[ny][nx] = 'x';
            dfs(ny, nx, ch);
        }
    }
}

int main() {
    while (cin >> n >> m and n and m) {
        rep(i, n) rep(j, m) {
            cin >> rc[i][j];
        }
        int ans = 0;
        rep(i, n) rep(j, m) {
            char tmp = rc[i][j];
            if (tmp != 'x') {
                rc[i][j] = 'x';
                dfs(i, j, tmp);
                ans++;
            }
        }
        cout << ans << endl;
    }
}