#include<iostream>
#include<string>
using namespace std;
int sum,m,n;
bool used[102][102];
char maps[102][102];
int a[8][2] = {{0,1},{0,-1},{1,0},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1}};
void Dfs(int i,int j)
{
int k;
int s,t;
if(used[i][j] == true)
return;
for(k = 0;k < 8;k++)
{
s = i + a[k][0];
t = j + a[k][1];
if(s < 0 || s >= n || t < 0 || t >= m)
continue;
if(maps[s][t] == '@' && used[s][t] == false)
{
used[s][t] = true;
Dfs(s,t);
}
}//while(!Q.empty())
}
int main()
{
int i,j;
while(cin>>n>>m)
{
if(n == 0 && m == 0)
break;
for(i = 0;i < n;i++)
scanf("%s",maps[i]);
for(i = 0;i < n;i++)
for(j = 0;j < m;j++)
used[i][j] = false;
sum = 0;
for(i = 0;i < n;i++)
{
for(j = 0;j < m;j++)
{
if(maps[i][j] == '@' && used[i][j] == false)
{
used[i][j] = true;
Dfs(i,j);
sum++;
}
}
}
printf("%d\n",sum);
}
return 0;
}
/**//*
#include<iostream>
#include<queue>
#include<string>
using namespace std;
typedef struct node
{
int x,y;
}Node;
queue<Node> Q;
int sum,m,n;
bool used[102][102];
char maps[102][102];
int a[8][2] = {{0,1},{0,-1},{1,0},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1}};
void Bfs(int i,int j)
{
Node p,q;
int k;
int s,t;
p.x = i;
p.y = j;
Q.push(p);
while(!Q.empty())
{
q = Q.front();
Q.pop();
for(k = 0;k < 8;k++)
{
s = q.x + a[k][0];
t = q.y + a[k][1];
if(s < 0 || s >= n || t < 0 || t >= m)
continue;
if(maps[s][t] == '@' && used[s][t] == false)
{
used[s][t] = true;
p.x = s;
p.y = t;
Q.push(p);
}
}
}//while(!Q.empty())
}
int main()
{
int i,j;
while(cin>>n>>m)
{
if(n == 0 && m == 0)
break;
for(i = 0;i < n;i++)
//cin>>maps[i];
scanf("%s",maps[i]);
for(i = 0;i < n;i++)
for(j = 0;j < m;j++)
used[i][j] = false;
sum = 0;
for(i = 0;i < n;i++)
{
for(j = 0;j < m;j++)
{
if(maps[i][j] == '@' && used[i][j] == false)
{
used[i][j] = true;
Bfs(i,j);
sum++;
}
}
}
printf("%d\n",sum);
//cout<<sum<<endl;
}
return 0;
}
*/