/* ***************************
   ??????????§????
   ???????????????
   ????????????????????¨????????±???????????¢?´¢
   *************************** */

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

#define MAX 20

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

// ??????????????¨ ?§???????
typedef struct _stack {
  struct _stack *next;
  Coord point;
} *stack, stackelem;

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

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

// ??????????????¨
stack  new_stack (void);
int is_empty (stack);
int push (stack, Coord);
Coord top (stack);
Coord pop (stack);

// main ??¢??°
int main () {
  int W, H;

  while(1){
    scanf("%d%d", &W, &H);
    if(W==0 && H==0)break;
    /*if (W<1 || H<1 || W>MAX || H>MAX) {
      printf("?????¢??????????????? %d X %d ?????§??§???. \n", MAX, MAX);
      } 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_df(W, H, start);
}

int search_df (int W, int H, Coord start) {
  int count = 1;
  stack S = new_stack ();  // ?¨?????????????????????????????????????

  // ??????????????°???????¨????
  push(S,start);                               // ??????????????°?????? push
  // ??¢?´¢
  while (!is_empty(S)) {
    Coord current = pop(S);                    // pop ???????????????
    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
      // ????????§???????????????
      nc.row += D1[d]; nc.col += D2[d];

      
      if(M[nc.row][nc.col] == '.'){
	push(S, nc);
	M[nc.row][nc.col] = '*';
	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');
}

/* ??°??????????????????????¢?????????????????????? */
stack new_stack (void) {
  stack s;
  s = (stack) malloc (sizeof (stackelem));
  if (s == NULL) return NULL;
  s->next = NULL;
  return s;
}
    
/* ???????????????????????????????????? */
int is_empty (stack s) {
  return (s && s->next == NULL);
}

/* ??°??????????´???????????????\ */
int push (stack s, Coord v) {
  stack p;
  if (s == NULL) return 0;
  p = (stack) malloc (sizeof (stackelem));
  if (p == NULL) return 0;
  p->point = v;
  p->next = s->next;
  s->next =  p;
  return 1;
}

/* ?????????????´?????????? */
Coord top (stack s) {
  if (s && s->next) 
    return s->next->point;
  exit (1);
}

/* ????????? */
Coord pop (stack s) {
  stack p;
  Coord v = top (s);
  p = s->next;
  s->next = p->next;
  free (p);
  return v;
}

Measured memory_bytes: 616