#include<stdio.h>

int tf[20][20];

int judge(int x,int y,int w,int h){
  int cnt=1;
  int i,j;
  tf[x][y]=1;
  if(x-1>=0){
    if(tf[x-1][y]==0){
      cnt+=judge(x-1,y,w,h);
    }
  }
  if(y-1>=0){
    if(tf[x][y-1]==0){
      cnt+=judge(x,y-1,w,h);
    }
  }
  if(x+1<=h-1){
    if(tf[x+1][y]==0){
      cnt+=judge(x+1,y,w,h);
    }
  }
  if(y+1<=w-1){
    if(tf[x][y+1]==0){
      cnt+=judge(x,y+1,w,h);
    }
  }
  return cnt;
}

void doit(int w,int h){
  char maze[h][w+1];
  int x,y;
  int i,j;
  for(i=0;i<h;i++){
    scanf("%s",maze[i]);
    for(j=0;j<w;j++){
      if(maze[i][j]=='#'){
	tf[i][j]=1;
      }
      else{
	tf[i][j]=0;
	if(maze[i][j]=='@'){
	  x=i;
	  y=j;
	}
      }
    }
  }
  printf("%d\n",judge(x,y,w,h));
}

int main(){
  int w,h;
  scanf("%d %d",&w,&h);
  while(w!=0){
    doit(w,h);
    scanf("%d %d",&w,&h);
  }
  return 0;
}