#include<stdio.h>

const int INF = 10000000;

int W, H, bx, by;
char tile[21][21];
int d[21][21];
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};


void bfs();

void solve();


int main(){
  int i, j;
  while(scanf("%d%d", &W, &H) && (W || H)){
    //scanf("%d%d", &W, &H);
      for(i = 0 ; i < H; i++){
        scanf("%s", tile[i]);
      }
      for(i = 0; i < W; i++){
        for(j = 0; j < H; j++){
          if(tile[j][i] == '@'){
            bx = i;
            by = j;
          }
        }
      }
      //printf("%d %d\n", bx, by);
      solve();
    }
  return 0;
}

void bfs(){
  struct pair{
    int first;
    int second;
  };

  struct queue{
    struct pair P[101];
    int head;
    int tail;
  };

  struct queue que;
  que.head = 0;
  que.tail = 0;
  int i, j;
  for(i = 0; i < W; i++){
    for(j = 0; j < H; j++){
      d[j][i] = INF;
    }
  }

  que.P[que.tail].first = bx;
  que.P[que.tail].second = by;
  d[by][bx] = 0;
  que.tail++;
  //que.head++;

  while(que.head < que.tail){
    struct pair state;
    state.first = que.P[que.head].first;
    state.second = que.P[que.head].second;
    que.head++;
    //printf("%d %d\n" ,que.head, que.tail);
    //if(p.first == gx && p.second == gy) break;

    for(i = 0; i < 4; i++){
      int nx = state.first + dx[i], ny = state.second + dy[i];

      if(0 <= nx && nx < W && 0 <= ny && ny < H && tile[ny][nx] != '#' && d[ny][nx] == INF){
        que.P[que.tail].first = nx;
        que.P[que.tail].second = ny;
        que.tail++;
        d[ny][nx] = d[state.first][state.second] + 1;
      }
    }
  }
  //return d[gx][gy];

}

void solve(){
  bfs(bx, by);
  int ans = 0, i, j;
  for(i = 0; i < W; i++){
    for(j = 0; j < H; j++){
      //printf("%d\n", d[i][j]);
      if(d[j][i] != INF) ans++;
    }
  }
  //printf("%d\n",INF);
  printf("%d\n", ans);
}