#include <stdio.h>
#define SIZE 20

/* ---------------------------------------------------------------------------- */

typedef unsigned short point;
#define point(y, x) (((y)<<8) | (x))
#define x(pt) ((pt) & 255)
#define y(pt) (((pt)>>8) & 255)

/* ---------------------------------------------------------------------------- */

point queue[SIZE*SIZE], pp, gp;
#define put(pt) (queue[pp++] = pt)
#define get() (queue[gp++])
#define empty() (gp == pp)
#define init() (pp = gp = 0)

/* ---------------------------------------------------------------------------- */

#define search(y, x) (count++, map[y][x] = 'w', put(point(y, x)))

char map[SIZE][SIZE+1];

int main(void)
{
    int w, h, x, y, count; point p;

    while(scanf("%d %d%*c", &w, &h), w+h)
    {
        /* init, input */

        init(); count = 0;
        for(y=0; y<h; y++) gets(map[y]);

        /* search for start */

        for(y=0; y<h; y++)
            for(x=0; x<w; x++)
                if(map[y][x] == '@') goto OUTER;
      OUTER:

        /* search */

        search(y, x);

        while(!empty())
        {
            p = get(); x = x(p), y = y(p);
            if(x-1 >= 0 && map[y][x-1] == '.') search(y, x-1);
            if(x+1 <  w && map[y][x+1] == '.') search(y, x+1);
            if(y-1 >= 0 && map[y-1][x] == '.') search(y-1, x);
            if(y+1 <  h && map[y+1][x] == '.') search(y+1, x);
        }

        printf("%d\n", count);
    }

    return 0;
}