/* ***************************
   ??????????§????
   ???????????????
   ?????\???????????¨?????????????????¢?´¢
   *************************** */

#include<stdio.h>
#include<stdlib.h>

#define MAX 20

// ????????¨?????¨ ?§???????
typedef struct {
  int row;               // ?????????
  int col;               // ?????????
} Coord;

// ?????\?????¨ ?§???????
typedef struct _que {
  struct _que *next;
  struct _que *prev;
  Coord point;
} *que, queelem;

typedef struct {
  que head;
  que tail;
} *queue, queueelem;

char M[MAX+2][MAX+2];    // ?????¢?????°??????????????§???

// ????????????????????£?¨?
int solve (int W, int H);
int search_bf (int W, int H, Coord start);
void display_map (int W, int H);

// ?????\?????¨
queue new_queue (void);
int is_empty (queue);
int enqueue (queue, Coord);
Coord dequeue (queue);

// main ??¢??°
int main () {
  int W, H;
  while(1){
    scanf("%d%d", &W, &H);
    // printf("%d %d",W,H);
    if(W==0&&H==0){
      break;
    }else{
      printf("%d\n", solve(W,H));
    }
  }
  return 0;
}

// ?????£?????¢?´¢ 
int solve (int W, int H) {
  Coord start;             // ??????????????°???
  int i, j;

  //  ?£?????????????????¨???? 
  for (i=0; i<=W+1; i++) { M[0][i] = '#'; M[H+1][i] = '#'; }
  for (i=1; i<=H; i++) { M[i][0] = '#'; M[i][W+1] = '#'; }
  // ??????????????\??? 
  for (i=1; i<=H; i++) {
    for (j=1; j<=W; j++) {
      scanf(" %c", &M[i][j]);
      if (M[i][j]=='@') {
	start.row = i;
	start.col = j;
      }
    }
  }

  // ??????????????°?????¨??? (??¬??\???????????????)
  // printf("??????????????°??? [%d, %d]\n\n", start.row, start.col);

  // ?????£?????°??????????????? 1, ????????§???????????? 0
  return search_bf(W, H, start);
}

int search_bf (int W, int H, Coord start) {
  queue Q = new_queue ();  // ?¨??????????????????????????????\???
  int count=1;
  // ??????????????°???????¨????
  enqueue(Q, start);                           // ??????????????°?????? enqueue
  // ??¢?´¢
  while (!is_empty(Q)) {
    Coord current = dequeue(Q);                // dequeue ???????????????
    int d;                                     // ??????
    int D1[]={1,0,-1,0}; int D2[]={0,-1,0,1};  // ????????¢?????¶?????¨
    //printf("?????¨??°??? [%d, %d]\n", current.row, current.col);  // ??¬??\???????????????
    //display_map(W, H); // ?????¨??????????????¨??? (??¬??\???????????????)
    for (d=0; d<4; d++) {
      Coord nc = current;                      // Next Cell
      // ????????§???????????????
      if('.'==M[nc.row+D1[d]][nc.col+D2[d]]){
	Coord coo;//queue???????´????????????????Coord????????°coo
	coo.row=nc.row+D1[d];
	coo.col=nc.col+D2[d];
	enqueue(Q,coo);
	M[nc.row+D1[d]][nc.col+D2[d]]='*';
	count++;	//?????§????????£?????´??????*????????´
      }
    }
  }
  return count;  // ??°??????????????¨????????´????????¢?´¢?????? 
}

void display_map (int W, int H) {;
  int i, j;
  for (i=1; i<=H; i++) {
    for (j=1; j<=W; j++) {
      printf("%c", M[i][j]);
    }
    putchar('\n');
  }
  putchar('\n');
}

/* ??°???????????\???????¢?????????????????????? */
queue new_queue (void) {
  queue q;
  q = (queue) malloc (sizeof (queueelem));
  if (q == NULL) return NULL;
  q->head = NULL;
  q->tail = NULL;
  return q;
}
    
/* ?????\??????????????????????????? */
int is_empty (queue q) {
  return (q && q->head == NULL);
}

/* ??°??????????´?????????\???????????? */
int enqueue (queue q, Coord v) {
  que p;
  if (q == NULL) return 0;
  p = (que) malloc (sizeof(queelem));
  if (p == NULL) return 0;
  p->point = v;
  p->next = NULL;
  if (q->tail) {
    p->prev = q->tail;
    q->tail->next = p;
  } else {
    /* queue ?????? */
    p->prev = NULL;
    q->head = p;
  }
  q->tail=p;
  return 1;
}

/* ?????\????????????????´???????????????? */
Coord dequeue (queue q) {
  que p;
  Coord v = q->head->point;
  p = q->head;
  if (p->next == NULL) {
    q->head = NULL;
    q->tail = NULL;
  } else {
    q->head = q->head->next;
    q->head->prev = NULL;
  }
  free (p);
  return v;
}