/*
Coder: Shawn_Xue
Date: 2015.4.4
Result: AC
*/
#include <iostream>
using namespace std;
const int maxn = 110;
char map[maxn][maxn];
bool visited[maxn][maxn];
const int dir[8][2] = { {1,0}, {1,1}, {1,-1}, {0,1}, {0,-1}, {-1,-1}, {-1,1}, {-1, 0}};
int m, n;
void dfs(int x, int y)
{
// 越界,边界要控制好
if(x < 1 || y < 1 || x > m || y > n) return;
// 空油田
if(map[x][y] == '*') return;
// 已访问
if(visited[x][y] == true)
return;
else visited[x][y] = 1;
int nx, ny;
for(int i = 0; i < 8; i++)
{
nx = x+dir[i][0];
ny = y+dir[i][1];
dfs(nx, ny);
}
}
int solves()
{
int count = 0;
for(int i = 1; i <= m; i ++)
for(int j = 1; j <= n; j ++)
{
//油田且没有被访问过
if(map[i][j] == '@' && visited[i][j] == false)
{
count ++;
dfs(i,j);
}
}
return count ;
}
int main()
{
while(cin >> m >> n && m)
{
for( int i = 1; i <= m; i ++)
for( int j = 1; j <= n; j ++)
{
cin >> map[i][j];
visited[i][j] = false;
}
cout << solves() << endl;
}
}