import std.stdio, std.string, std.conv, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

int[] di = [1,0,-1,0], dj = [0,1,0,-1];
int ans;

void main() {
    while (1) {
        int w, h;
        scan(w, h);

        if (!w) return;

        auto bd = iota(h).map!(i => readln.chomp.to!(char[])).array;
        int si, sj;

        foreach (i ; 0 .. h) {
            foreach (j ; 0 .. w) {
                if (bd[i][j] == '@') {
                    si = i, sj = j;
                    break;
                }
            }
        }

        ans = 0;
        dfs(h, w, bd, si, sj);

        writeln(ans);
    }
}

void dfs(int h, int w, char[][] bd, int i, int j) {
    ans++;
    bd[i][j] = '#';

    foreach (k ; 0 .. 4) {
        int ni = i + di[k];
        int nj = j + dj[k];

        if (ni < 0 || ni >= h || nj < 0 || nj >= w) continue;

        if (bd[ni][nj] == '.') {
            dfs(h, w, bd, ni, nj);
        }
    }

}


void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}