#include <iostream>
#include <cstdio>
#include <cstring>
#define bswap(a,b) a^=b^=a^=b
#define _for(i,a,b) for(int i = (a); i < b; ++i)
#define _rep(i,a,b) for(int i = (a); i <= b; ++i)
#define met(a) memset(a,0,sizeof(a))
#define _met(a) memset(a,-1,sizeof(a))

using namespace std;
const int maxn = 100+5;
char rec[maxn][maxn];
bool visited[maxn][maxn];
int dx[] = {1, 0, 0, -1};
int dy[] = {0, -1, 1, 0};
//pair<int, int> p;
int ans = 0;
int w, h;
void dfs(int x, int y, char c)
{
    rec[x][y] = '.';
    _for(i,0,4){
        int nowx = x + dx[i];
        int nowy = y + dy[i];
        if(0 <= nowx && nowx < h && 0 <= nowy && nowy < w &&
           rec[nowx][nowy] == c){

            dfs(nowx, nowy, c);
        }
    }
}
int main()
{

    cin>>w>>h;
    while (getchar() != '\n') continue;
    while(w&&h)
    {
        memset(visited,0,sizeof visited);
        ans = 0;
        _for(i,0,h) _for(j,0,w) cin>>rec[i][j];
        _for(i,0,h) _for(j,0,w){
            if(rec[i][j] == '#'){
                ans++;
                dfs(i,j,rec[i][j]);
            }
            else if(rec[i][j] == '@'){
                ans++;
                dfs(i,j,rec[i][j]);
            }
            else if(rec[i][j] == '*'){
                ans++;
                dfs(i,j,rec[i][j]);
            }
        }
        cout<<ans<<endl;
        cin>>w>>h;
        while (getchar() != '\n')continue;
    }
    return 0;
}

