import std.algorithm;
import std.array;
import std.stdio;
import std.conv;
import std.string;
import std.range;

void main(){
    size_t w, h, sx, sy;
    char[][] data = new char[][](20, 20);
    while(true){
        auto input = readln.split;
        w = input[0].to!int;
        h = input[1].to!int;
        if(!(w | h)){
            break;
        }
        foreach(i; 0..h){
            foreach(j, c; readln.chomp){
                data[i][j] = c;
                if(c == '@'){
                    sx = j;
                    sy = i;
                    data[i][j] = '#';
                }
            }
        }
        data.dfs(sx, sy, w, h).writeln;
    }
}

auto move = [[1, 0], [0, 1], [-1, 0], [0, -1]];

size_t dfs(char[][] data, size_t sx, size_t sy, size_t w, size_t h){
    size_t count = 1;
    foreach(i; 0..4){
        size_t x = sx + move[i][0];
        size_t y = sy + move[i][1];
        if(0 <= x && x < w && 0 <= y && y < h && data[y][x] != '#'){
            data[y][x] = '#';
            count += dfs(data, x, y, w, h);
        }
    }
    return count;
}