#include<stdio.h>

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

int search(int x, int y){
  int result=1;
  if(x<0 || x>=w||y<0 || y>=h) return 0;
  if(map[y][x]=='#') return 0;
  map[y][x]='#';
  result+=search(x-1,y);
  result+=search(x+1,y);
  result+=search(x,y-1);
  result+=search(x,y+1);

  return result;
}

int main(){
  int i,j;
  int sx, sy;
  while(scanf("%d%d", &w,&h), w!=0&&h!=0){
    for(i=0; i<h; i++){
      scanf("%s", map[i]);
      for(j=0; j<w; j++){
	if(map[i][j]=='@') sx=j,sy=i;
      }
    }
    printf("%d\n", search(sx,sy));
  }
  return 0;
}

 