#include <stdio.h>

char s[20][21];
int w, h;
int count = 0;

void search(int pos_x, int pos_y) {
    switch (s[pos_y][pos_x]) {
        case '.': case '@':
            s[pos_y][pos_x] = '/';
            count++;
            break;
        default:
            return;
    }

    // right
    if (pos_x < w - 1) search(pos_x + 1, pos_y);
    // down
    if (pos_y < h - 1) search(pos_x, pos_y + 1);
    // left
    if (pos_x > 0) search(pos_x - 1, pos_y);
    // up
    if (pos_y > 0) search(pos_x, pos_y - 1);
}

int main() {
    int pos_x = -1, pos_y = -1;
    int i, j;

    while (1) {
        // initialize
        count = 0;
        pos_x = -1, pos_y = -1;

        // read
        scanf(" %d %d", &w, &h);

        if (w == 0 || h == 0) break;

        for (i = 0; i < h; i++) {
            scanf(" %s", s[i]);

            if (pos_x != -1) continue;
            for (j = 0; j < w; j++) {
                if (s[i][j] != '@') continue;

                pos_x = j;
                pos_y = i;
                break;
            }
        }

        // solve
        search(pos_x, pos_y);
        printf("%d\n", count);
    }

    return 0;
}