#include"stdio.h"
#include"queue"
#include"stdlib.h"
using namespace std;
int dir[4][2] = { 0,1,0,-1,-1,0,1,0 };
char map[20][20];
int W, H,num;
struct node { int x, y; };
#define check(x, y) (x<W && x>=0 && y >=0 && y<H)
void BFS(int dx, int dy)
{
num = 1;
queue<node>q;
node start, next;
start.x = dx; start.y = dy;
q.push(start);
while (!q.empty())
{
start = q.front();
q.pop();
for (int i = 0; i < 4; i++)
{
next.x = start.x + dir[i][0];
next.y = start.y + dir[i][1];
if (check(next.x, next.y) && map[next.x][next.y] == '.')
{
num++;
map[next.x][next.y] = '#';
q.push(next);
}
}
}
}
int main()
{
int dx, dy;
while (scanf("%d%d", &W, &H)!=EOF)
{
getchar();
if (W == 0 || H == 0)break;
for (int j = 0; j < H; ++j)
{
for (int i = 0; i < W; ++i)
{
scanf("%c", &map[i][j]);
if (map[i][j] == '@')
{
dx = i; dy = j;
}
}
getchar();
}
num = 0;
BFS(dx, dy);
printf("%d\n", num);
}
return 0;
}