#include <stdio.h>

int a[20][20];
int w,h,i,j,o,p;
char str[20];
char kara;
int count;

void go(int x, int y) {
  //  printf("start go\n");
  //  printf("a[%d][%d] = %d\n",x,y,a[x][y]);

  a[x][y] = 2;

  // printf("a[%d][%d] = %d\n",x,y,a[x][y]);
  
  if(a[x+1][y] == 1 && w -1 > x) {
    count++;
    go(x+1,y);
  }
  if(a[x-1][y] == 1 && 0 < x) {
    count++;
    go(x-1,y);
  } if(a[x][y+1] == 1 && h-1 > y) {
    count++;
    go(x,y+1);
  }  if(a[x][y-1] == 1 && 0 < y) {
    //printf("start y-1\n");
    count++;
      go(x,y-1);
  }

}



int main() {



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


  // @ = 0  . = 1 # = 2
    for(j=0;j<h;j++) {
      scanf("%s",str);
      for(i=0;i<w;i++) {
      
      if(str[i] == '.') {
	a[i][j] = 1;
      }else if(str[i] == '@') {
	a[i][j] = 0;
	o = i;
	p  = j;
      }else if(str[i] == '#') {
	  a[i][j] = 2;
	}
      }
    }

    /*    for(i=0;i<h;i++) {
      for(j=0;j<w;j++){
	printf("%d ",a[j][i]);
      }
      printf("\n");
    }
    */

    //  printf("o = %d\np = %d\n",o,p);
    count = 0;
    go(o,p);


    /*   printf("\n");
  for(i=0;i<h;i++) {
      for(j=0;j<w;j++){
	printf("%d ",a[j][i]);
      }
      printf("\n");
    }
    */

    printf("%d\n",count+1);


  }

  return 0;

}