#include<stdio.h>

int main(){
  char tmp[1000];
  int h,w;
  char *board[40];

  while(scanf("%d%d",&w,&h),w+h){
    int i,j;
    memset(tmp,'#',sizeof(tmp));
    for(i=1;i<=h;i++){
      char buff[40];
      scanf("%s",buff);
      board[i]=&tmp[(w+2)*i];
      memcpy(board[i]+1,buff,w);
    }
    board[0]=tmp;
    board[h+1]=&tmp[(w+2)*(h+1)];

    int f=1;
    int ans=1;
    while(f){
      f=0;
      for(i=1;i<h+1;i++){
	for(j=1;j<w+1;j++){
	  if(board[i][j]=='@'){
	    int x,y;
	    for(y=-1;y<=1;y++){
	      for(x=-1;x<=1;x++){
		if(x*y!=0) continue;
		if(board[i+y][j+x]=='.'){
		  board[i+y][j+x]='@';
		  f=1;
		  ans++;
		}
	      }
	    }
	  }
	}
      }
    }

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

  return 0;
}