#include <iostream>
#include <cstdio>
#include <string>
#include <utility>
#include <queue>

using namespace std;

int fluit[100][100] = {0};

void blow(int i, int j, int w, int h, int n)
{
	queue<pair<int, int> > st;

	st.push(make_pair(i, j));
	
	while(1)
	{
		if(st.empty())	break;
		int x = st.front().second, y = st.front().first; 

		fluit[y][x] = 0;

		if(y - 1 >= 0){
			if(fluit[y - 1][x] == n)
				st.push(make_pair(y-1, x));
		}
		if(y + 1 < h){
		    if(fluit[y + 1][x] == n)
				st.push(make_pair(y+1, x));
		}
		if(x - 1 >= 0){
		    if(fluit[y][x - 1] == n)
				st.push(make_pair(y, x-1));
		}
		if(x + 1 < w){
		    if(fluit[y][x + 1] == n)
				st.push(make_pair(y, x+1));
		}

		st.pop();
	}
}

int main()
{
	int h, w, cont = 0;
	string str;

	while(cin >> h >> w){
		if(h == 0 && w == 0)	break;

		for(int i = 0; i < h; i++){
			cin >> str;

			for(int j = 0; j < w; j++){
				if(str[j] == '@')          fluit[i][j] = 1;
				else if(str[j] == '#')    fluit[i][j] = 2;
				else if(str[j] == '*')    fluit[i][j] = 3;
			}
		}

		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				if(fluit[i][j]){
					cont++;
					blow(i, j, w, h, fluit[i][j]);
				}
			}
		}

		cout << cont << endl;
	}

	return 0;
}

		