#include <stdio.h>

int a[22][22];
int w,h;

int r(int x,int y){
  int rtn = 1;
  a[x][y] = 0;

  if( a[x-1][y  ]==1 ) rtn += r( x-1,y   );
  if( a[x  ][y-1]==1 ) rtn += r( x  ,y-1 );
  if( a[x  ][y+1]==1 ) rtn += r( x  ,y+1 );
  if( a[x+1][y  ]==1 ) rtn += r( x+1,y   );
  return rtn;
}
int main(void){
  int i,j;
  char c;
  int x,y;

  while( 1 ){
    scanf("%d %d ",&w,&h );
    if( !w && !h )
      break;

    for( i=0;i<=h+1;i++){
      for( j=0;j<=w+1;j++ ){
	if( i==0 || i==h+1 || j==0 || j==w+1 ){
	  a[i][j] = 0;
	  continue;
	}

	scanf("%c ",&c );
	if( c=='.' ){
	  a[i][j] = 1;// black
	}else if( c=='#' ){
	  a[i][j] = 0;// red
	} else{
	  a[i][j] = 1;
	  x=i;y=j;
	}
      }
    }

    printf("%d\n",r(x,y) );
  }
  return 0;
}