#include <cstdio>
#include <iostream>
#include <sstream>
#include <cstdlib>
#include <algorithm>
#include <ctime>
#include <cctype>
#include <cmath>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <deque>
#include <list>
#include <vector>
#include <map>
#include <set>
#define sqr(x) ((x)*(x))
#define PI 3.1415926535897932384626
#define jue(x) (x>0?x:-x)
 
#define maxm 
#define maxn 1010
using namespace std;

int res;
int w, h;
int d1[4] = {1, -1, 0, 0};
int d2[4] = {0, 0, 1, -1};

char room[105][105];

void dfs(int x, int y, char z){
	room[x][y] = 'q';
	for(int i = 0; i < 4; i++){
		int xx = x + d1[i], yy = y + d2[i];
		if(0 <= xx && xx < h && 0 <= yy && yy < w && room[xx][yy] == z){
			dfs(xx, yy, z);
		} 
	}
}

int main(){
	while(scanf("%d %d", &w, &h) == 2){
		if(!w && !h){
            break;
        }
		for(int i = 0; i < h; i++){
			getchar();
			for(int j = 0; j < w; j++){
				scanf("%c", &room[i][j]);
			}
		}
		res = 0;
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				if(room[i][j] != 'q'){
					dfs(i, j, room[i][j]);
					res++;
				}
			}
		}
		printf("%d\n", res);
	}
	return 0;
}