#include <iostream>
#include <stdio.h>
#include <string.h>
#include <queue>
#define maxn 40
using namespace std;
char map[maxn][maxn];
bool vis[maxn][maxn];
int n,m,ans;
void bfs( int x, int y)
{
if(vis[x][y] || map[x][y] == '#')
return ;
ans++;
vis[x][y] = true;
bfs(x-1,y);
bfs(x,y-1); bfs(x,y+1);
bfs(x+1,y);
}
int main( )
{
while(scanf("%d%d",&n, &m)!=EOF, n &&m)
{
ans = 0;
int i,j,x,y;
bool flag = 1;
memset(map,'#',sizeof(map));
memset(vis,false,sizeof(vis));
for( i = 1; i <= m; i++)
{
cin.get();
for( j = 1; j <= n; j++)
{
cin>>map[i][j];
if(map[i][j] == '@' && flag)
{
x = i;
y = j;
flag = 0;
}
}
}
bfs(x,y);
cout<<ans<<endl;
}
}
#include <stdio.h>
#include <string.h>
#include <queue>
#define maxn 40
using namespace std;
char map[maxn][maxn];
bool vis[maxn][maxn];
int n,m,ans;
void bfs( int x, int y)
{
if(vis[x][y] || map[x][y] == '#')
return ;
ans++;
vis[x][y] = true;
bfs(x-1,y);
bfs(x,y-1); bfs(x,y+1);
bfs(x+1,y);
}
int main( )
{
while(scanf("%d%d",&n, &m)!=EOF, n &&m)
{
ans = 0;
int i,j,x,y;
bool flag = 1;
memset(map,'#',sizeof(map));
memset(vis,false,sizeof(vis));
for( i = 1; i <= m; i++)
{
cin.get();
for( j = 1; j <= n; j++)
{
cin>>map[i][j];
if(map[i][j] == '@' && flag)
{
x = i;
y = j;
flag = 0;
}
}
}
bfs(x,y);
cout<<ans<<endl;
}
}