#include <iostream>
using namespace std;
char grid[101][101];
int m,n;
int dir[8][2]={ {-1,-1},{-1,0},{-1,1},{0,1},{1,1},{1,0},{1,-1},{0,-1} };
int i,xx,yy;
int Answer = 0;
void DFS(int x,int y)
{
grid[x][y]='*';
for( i = 0; i < 8; i++ )
{
xx = x + dir[i][0];
yy = y + dir[i][1];
if( xx < 0 || yy < 0 || xx >= m || yy >= n )
{
continue;
}
if( grid[xx][yy] == '@' )
{
DFS( xx, yy );
}
}
}
int main(int argc, char** argv)
{
freopen("sample_input.txt", "r", stdin);
int count;
while( 1 )
{
cin>>m>>n;
if( m==0 )
{
break;
}
for( i = 0; i < m; i++ )
{
scanf("%s",&grid[i]);
}
count = 0;
for( i = 0; i < m; i++ )
{
for(int j = 0; j < n; j++ )
{
if( grid[i][j] == '@' )
{
DFS( i, j );
count++;
}
}
}
printf("%d\n",count);
}
return 0;
}
using namespace std;
char grid[101][101];
int m,n;
int dir[8][2]={ {-1,-1},{-1,0},{-1,1},{0,1},{1,1},{1,0},{1,-1},{0,-1} };
int i,xx,yy;
int Answer = 0;
void DFS(int x,int y)
{
grid[x][y]='*';
for( i = 0; i < 8; i++ )
{
xx = x + dir[i][0];
yy = y + dir[i][1];
if( xx < 0 || yy < 0 || xx >= m || yy >= n )
{
continue;
}
if( grid[xx][yy] == '@' )
{
DFS( xx, yy );
}
}
}
int main(int argc, char** argv)
{
freopen("sample_input.txt", "r", stdin);
int count;
while( 1 )
{
cin>>m>>n;
if( m==0 )
{
break;
}
for( i = 0; i < m; i++ )
{
scanf("%s",&grid[i]);
}
count = 0;
for( i = 0; i < m; i++ )
{
for(int j = 0; j < n; j++ )
{
if( grid[i][j] == '@' )
{
DFS( i, j );
count++;
}
}
}
printf("%d\n",count);
}
return 0;
}