#include <iostream>
#include <stdio.h>
#include <string.h>
#include <queue>
#define maxn 25
using namespace std;
char map[maxn][maxn];
int movex[4] = {0, 0, -1, 1};
int movey[4] = {1, -1, 0 ,0};
int w,h,ans,sx,sy;
void dfs( int x, int y)
{
//cout<<x<<y<<endl;
for( int i =0 ; i<4; i++)
{
int tx = x + movex[i];
int ty = y + movey[i];
if(tx>=1 && tx<=h && ty>=1 && ty<=w && map[tx][ty]=='.')
{
ans += 1;
map[tx][ty] = '#';
dfs(tx,ty);
//map[tx][ty] = '.';
}
}
}
int main()
{
while(scanf("%d%d",&w, &h),w &&h)
{
int i ,j;
ans = 1;
memset(map,'#',sizeof(map));
//getchar();
for( i = 1 ; i <= h; i++)
{
getchar();
for( j = 1; j<= w; j++)
{
scanf("%c",&map[i][j]);
if(map[i][j] == '@')
{
sx = i;
sy = j;
map[i][j] = '#';
}
}
}
dfs(sx,sy);
cout<<ans<<endl;
}
}
#include <stdio.h>
#include <string.h>
#include <queue>
#define maxn 25
using namespace std;
char map[maxn][maxn];
int movex[4] = {0, 0, -1, 1};
int movey[4] = {1, -1, 0 ,0};
int w,h,ans,sx,sy;
void dfs( int x, int y)
{
//cout<<x<<y<<endl;
for( int i =0 ; i<4; i++)
{
int tx = x + movex[i];
int ty = y + movey[i];
if(tx>=1 && tx<=h && ty>=1 && ty<=w && map[tx][ty]=='.')
{
ans += 1;
map[tx][ty] = '#';
dfs(tx,ty);
//map[tx][ty] = '.';
}
}
}
int main()
{
while(scanf("%d%d",&w, &h),w &&h)
{
int i ,j;
ans = 1;
memset(map,'#',sizeof(map));
//getchar();
for( i = 1 ; i <= h; i++)
{
getchar();
for( j = 1; j<= w; j++)
{
scanf("%c",&map[i][j]);
if(map[i][j] == '@')
{
sx = i;
sy = j;
map[i][j] = '#';
}
}
}
dfs(sx,sy);
cout<<ans<<endl;
}
}