#include <stdio.h>

int h, w;
char mp[25][25];
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};

int dfs(int sy, int sx);

int main()
{
    scanf("%d %d", &w, &h);
    while (h != 0 && w != 0) {

        int sy, sx;

        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                scanf(" %c ", &mp[i][j]);

                if (mp[i][j] == '@') {
                    sy = i;
                    sx = j;
                }
            }
        }

        printf("%d\n", dfs(sy, sx));
        
        scanf("%d %d", &w, &h);
    }

    return 0;
}

int dfs(int y, int x)
{
    if (y < 0 || y >= h ||
        x < 0 || x >= w ||
        mp[y][x] == '#') {
        return 0;
    }

    int rec = 1;
    mp[y][x] = '#';

    for (int i = 0; i < 4; i++) {
        int ny = y + dy[i];
        int nx = x + dx[i];

        rec += dfs(ny, nx);
    }

    return rec;
}

