#include <cstdio>
#include <cstdlib>
#include <queue>
#include <cstring>
using namespace std;
const int N = 110;
char matrix[N][N];
bool isTrue[N][N];
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void change(int H, int W, int sx, int sy, char ch) {
    queue<pair<int, int> > que;
    que.push(pair<int, int>(sx, sy));
    while(que.size()) {
        int nx = que.front().first;
        int ny = que.front().second;
        que.pop();
        for(int i = 0; i < 4; i++) {
            int x = nx + dx[i];
            int y = ny + dy[i];
            if(0 <= x && x < H && 0 <= y && y <= W && isTrue[x][y] == false && matrix[x][y] == ch) {
                isTrue[x][y] = true;
                matrix[x][y] = '.';
                que.push(pair<int, int>(x, y));
            }
        }
    } 
}

int solve(int H, int W) {
    int count = 0;
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            if(matrix[i][j] != '.') {
                change(H, W, i, j, matrix[i][j]);
                count++;
            } 
        }
    }
    return count;
}

int main() {
    int row = 1, col = 1;
    while(scanf("%d%d", &row, &col) && row !=0 && col != 0) {
        memset(isTrue, 0, sizeof(isTrue));
        for(int i = 0; i < row; i++) {
            scanf("%s", matrix[i]);
        }
        printf("%d\n", solve(row, col));
    }
}
