#include<stdio.h>

int w;
int h;
char map[20][21];

int solve(int x,int y){
  int count=1;

  if(x+1<w&&map[y][x+1]=='.'){
    map[y][x+1]='f';
    count+=solve(x+1,y);
  }
  if(x-1>-1&&map[y][x-1]=='.'){
    map[y][x-1]='f';
    count+=solve(x-1,y);
  }
  if(y+1<h&&map[y+1][x]=='.'){
    map[y+1][x]='f';
    count+=solve(x,y+1);
  }
  if(y-1>-1&&map[y-1][x]=='.'){
    map[y-1][x]='f';
    count+=solve(x,y-1);
  }
  return count;
}

int main(){
  int i,j,mx,my,found;
  do{
    found=0;
    scanf("%d %d",&w,&h);
    if(w==0&&h==0) break;
    for(i=0;i<h;i++){
      scanf("%s",map[i]);
      if(!found){
	for(j=0;j<w;j++){
	  if(map[i][j]=='@'){
	    mx=j;
	    my=i;
	    found=1;
	  }
	}
      }
    }
    printf("%d\n",solve(mx,my));
  }while(1);
  return 0;
}
      