#include <stdio.h>
#include <string.h>
 
char map[22][22], mk[22][22];
int que[500][2], top, end;
int m[4][2] = {{1,0},{-1,0},{0,-1},{0,1}};
 
int main()
{
    int w, h, i, r, c, r2, c2, ans;
     
    while (scanf("%d%d", &w, &h) && w) {
        memset(mk, 0, sizeof(mk));
        for (i = 0, r = 0; r < h; r++) {
            scanf("%s", map[r]);
            for (c = 0; c < w; c++) if (map[r][c] == '@') {
                que[0][0] = r, que[0][1] = c; mk[r][c] = 1, top = 0, end = 1, i = 1;
            }
        }
        while (top < end) {
            r = que[top][0], c = que[top++][1];
            for (i = 0; i < 4; i++) {
                r2 = r + m[i][0], c2 = c + m[i][1];
                if (r2 < 0 || r2 >= h || c2 < 0 || c2 >= w || map[r2][c2] == '#') continue;
                if (mk[r2][c2]) continue;
                mk[r2][c2] = 1;
                que[end][0] = r2, que[end++][1] = c2;
            }
        }
        for (ans = 0, r = 0; r < h; r++) for (c = 0; c < w; c++) ans += mk[r][c];
        printf("%d\n", ans);
    }
    return 0;
}
