/*
AizuOnline A1130
Red and Black
*/
#include <stdio.h>

char tile[20][21];
int W,H;

void find_start(int * x,int * y)
{
  int i,j;

  for(i=0;i<H;i++)
    for(j=0;j<W;j++)
      if(tile[i][j] == '@')
	{
	  *x = j;
	  *y = i;
	  return;
	}
  *x=*y=0;
}
int count_black(x,y)
{ int ret;
  ret=0;

  if(tile[y][x]=='@' || tile[y][x]=='.')
    {
      ret=1;
      tile[y][x]='*';
      if(x < W-1)
	ret += count_black(x+1,y);
      if(x > 0)
	ret += count_black(x-1,y);
      if(y < H-1)
	ret += count_black(x,y+1);
      if(y > 0)
	ret += count_black(x,y-1);
    }
  return(ret);
}

main()
{
  int i,x,y,ret;

  while(EOF!=scanf("%d %d",&W, &H) && ((W > 0) || (H > 0)))
    {
      for(i=0;i<H;i++)
	scanf("%s",&(tile[i][0]));

      find_start(&x,&y);

      ret=count_black(x,y);

      printf("%d\n",ret);
    }


return(0);
}