#include <iostream>
#include <stdio.h>
#include <string.h>
#define maxn 200
using namespace std;
char map[maxn][maxn];
bool vis[maxn][maxn];
int n,m;
void dfs(int x, int y)
{
if(vis[x][y] || map[x][y] == '*')
return ;
vis[x][y] = true;
dfs(x-1,y-1); dfs(x-1,y); dfs(x-1,y+1);
dfs(x,y-1); dfs(x,y+1);
dfs(x+1,y-1); dfs(x+1,y); dfs(x+1,y+1);
}
int main()
{
while(scanf("%d%d",&n, &m),n&&m)
{
int count = 0;
memset(vis,false,sizeof(vis));
memset(map,'*',sizeof(map));
for( int i = 1; i<= n; i++)
{ getchar();
for( int j = 1; j<= m; j++)
cin>>map[i][j];
}
for( int i = 1; i<= n; i++)
for( int j =1; j<= m; j++)
{
if(map[i][j] == '@' && !vis[i][j] )
{
count++;
dfs(i,j);
}
}
printf("%d\n",count);
}
return 0;
}
#include <stdio.h>
#include <string.h>
#define maxn 200
using namespace std;
char map[maxn][maxn];
bool vis[maxn][maxn];
int n,m;
void dfs(int x, int y)
{
if(vis[x][y] || map[x][y] == '*')
return ;
vis[x][y] = true;
dfs(x-1,y-1); dfs(x-1,y); dfs(x-1,y+1);
dfs(x,y-1); dfs(x,y+1);
dfs(x+1,y-1); dfs(x+1,y); dfs(x+1,y+1);
}
int main()
{
while(scanf("%d%d",&n, &m),n&&m)
{
int count = 0;
memset(vis,false,sizeof(vis));
memset(map,'*',sizeof(map));
for( int i = 1; i<= n; i++)
{ getchar();
for( int j = 1; j<= m; j++)
cin>>map[i][j];
}
for( int i = 1; i<= n; i++)
for( int j =1; j<= m; j++)
{
if(map[i][j] == '@' && !vis[i][j] )
{
count++;
dfs(i,j);
}
}
printf("%d\n",count);
}
return 0;
}