#include "stdio.h"
#include "stdlib.h"
#include "iostream"
#include "math.h"
#include <string.h>


using namespace std;
#define fori0(G) for(int i=0;i<G;i++)
#define fori1(G) for(int i=1;i<=G;i++)
#define forj0(G) for(int j=0;j<G;j++)
#define forj1(G) for(int j=1;j<=G;j++)
#define fork0(G) for(int k=0;k<G;k++)
#define fork1(G) for(int k=1;k<=G;k++)

int h, w;
char ch[200][200];
int fl[200][200];

void dfs(int x, int y) {
	fl[x][y] = 0;
	int dx[] = { -1,0,1,0 };
	int dy[] = { 0,1,0,-1 };
	int nx, ny;
	printf("(%d,%d)", x, y);
	fori0(4) {
		
		nx = x + dx[i];
		ny = y + dy[i];
		if (0 <= nx && nx < h && 0 <= ny && ny < w&&fl[nx][ny]&&ch[x][y]==ch[nx][ny]) { dfs(nx, ny); }
	}
	return;

}

int main() {
	int co;
	


	while (1) {
		co = 0;
		cin >> h >> w;
		if (h == 0 && w == 0)break;
		fori0(h)forj0(w) {
			cin >> ch[i][j];
			fl[i][j] = 1;
		}
		fori0(h)forj0(w) {
			if (fl[i][j]) {
				//fl[i][j] = 0;
				co++;
				dfs(i, j);
			}
		}
		printf("%d\n", co);
	}
	//system("pause");
	return 0;
}
