#include <cmath>
#include <ctime>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <cstdio>
#include <cctype>
#include <queue>
#include <complex>
#include <climits>

typedef long long ll;

using namespace std;

int W, H;
char field[30][30];

void dfs(int x, int y, char obj){
	field[x][y] = 'T';

	for(int dx = -1; dx <= 1; ++dx){
		for(int dy = -1; dy <= 1; ++dy){
			if(dx != 0 && dy != 0) continue;
			int nx = x + dx, ny = y + dy;
			if(0 <= nx && nx < H && 0 <= ny && ny < W && field[nx][ny] == obj){
				dfs(nx, ny, obj);
			}
		}
	}

	return ;
}

int main(void){
	while(1){
		cin >> H, cin >> W;
		if(!W && !H) break;

		int sx, sy;

		for(int i=0; i<H; ++i){
			for(int j=0; j<W; ++j){
				cin >> field[i][j];
			}
		}

		int count = 0;

		for(int i=0; i<H; ++i){
			for(int j=0; j<W; ++j){
				if(field[i][j] == '#' || field[i][j] == '@' || field[i][j] == '*'){
					dfs(i, j, field[i][j]);
					count++;
				}
			}
		}

		cout << count << endl;
	}

	return 0;
}

	