#include<stdio.h>
#include<string.h>

typedef struct {
  int x, y;
} Point;

int W, H;
char mas[20][21];
int i, j;


int main()
{
  while(scanf("%d %d", &W, &H), W) {
    getchar();
    for(i = 0; i < H; i++) {
      scanf("%s", mas[i]);
    }

    const int SIZE = 60000;
    int head = 0, tail = 1;
    int cnt = 0;
    Point z[SIZE], start;

    for(i = 0; i < H; i++) {
      for(j = 0; j < W; j++) {
	if(mas[i][j] == '@') start = (Point){j, i};
      }
    }

    z[head] = start;
    const int dy[] = {0, 1, 0, -1}, dx[] = {-1, 0, 1, 0};

    while(head != tail) {
      int x = z[head].x, y = z[head].y;
      head = (head + 1) % SIZE;
      if(0 <= x && x < W && 0 <= y && y < H && mas[y][x] != '#') {
	mas[y][x] = '#';
	++cnt;
	for(i = 0; i < 4; i++) {
	  int ny = dy[i] + x, nx = y + dx[i];
	  z[(tail + i) % SIZE] = (Point){ny, nx};
	}
	tail = (tail + 4) % SIZE;
      }
    }
    printf("%d\n", cnt);
  }
  return(0);
}