#include <stdio.h>

int solve(int W, int H){
  char room[20][20];
  int x, y, i;
  
  for(i = 0; i < H; i++){
    scanf("%s\n", room[i]);
  }

  for(y = 0; y < H; y++){
    for(x = 0; x < W; x++){
      if(room[y][x] == '@')
	return dfs(room , W, H, x, y, 0);
    }
  }
  return 0;
}

int dfs(char room[][20], int W, int H, int x, int y, int n){
  int nx, ny, i;
  if(room[y][x] == '@') n = 1;
  else if(room[y][x] == '.') n++;

  room[y][x] = '/';

  for(i = 0; i < 4; i++){
    switch(i){
    case 0:  //left
      nx = x - 1;
      ny = y;
      break;
    case 1:  //up
      nx = x;
      ny = y - 1;
      break;
    case 2:  //right
      nx = x + 1;
      ny = y;
      break;
    case 3:  //down
      nx = x;
      ny = y + 1;
      break;				      
    } 
    if((0 <= nx && nx < W) && (0 <= ny && ny < H)){
      if(room[ny][nx] == '.'){
	n = dfs(room, W, H, nx, ny, n);
      }
    }
  }
  return n;
}

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