#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

const int MAXW = 110, MAXH = 110;

char tile[MAXW][MAXH];

int dx[] = {-1,1,0,0};
int dy[] = {0,0,-1,1};
int ss;
int solve(int x, int y, char c)
{
    if(tile[x][y] == 0) return 0;
    
    tile[x][y] = 0;
    REP(4)if(tile[x+dx[i]][y+dy[i]] == c) {solve(x+dx[i], y+dy[i] , c);}
    
    return 1;
}

int main()
{
    int w,h;
    while(cin >> h >> w && h)
    {
        memset(tile, 0, sizeof(tile));
        rep(j,h)rep(i,w)cin >> tile[i+1][j+1];

        int ans = 0;
        rep(j,h)rep(i,w) ans += solve(i+1, j+1, tile[i+1][j+1]);

        cout << ans << endl;
    }

    return 0;
}