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

int visited[30][30];
char map[30][30];
int dr[]={-1, 0, 1, 0}, dc[]={0, -1, 0, 1};
int h, w, res;

void dfs(int r, int c)
{
    int i;
    if (visited[r][c]) return;
    map[r][c]='X';
    visited[r][c]=1;
    ++res;
    for(i=0;i<4;++i) {
        int nr=r+dr[i], nc=c+dc[i];
        if (nr<0 || nr>=h || nc<0 || nc>=w || visited[nr][nc] || map[nr][nc]!='.') continue;
        dfs(nr, nc);
    }
}

int main()
{
    while (1) {
        int i, j, sr, sc;
        scanf("%d%d", &w, &h);
        if (w==0) break;

        memset(map, 0, sizeof(map));
        memset(visited, 0, sizeof(visited));
        for(i=0;i<h;++i) {
            scanf("%s", map[i]);
            for(j=0;j<w;++j) if (map[i][j]=='@') { sr=i, sc=j; }
        }

        res=0;
        dfs(sr, sc);
        printf("%d\n", res);
    }
    return 0;
}