#include<stdlib.h>
#include<stdio.h>
#define TRUE 1
#define MAX 22

int map[MAX][MAX];
int w,h;
int count;

void move();

int main(void) {
	int x,y;
	char buff;
	int i,j;
	
	while(TRUE) {
		scanf("%d %d", &w, &h);
		if(w==0 && h==0) break;
		for(i=0;i<MAX;i++) {
			for(j=0;j<MAX;j++) {
				map[i][j] = 0;
			}
		}
		
		for(i=1;i<=h;i++) {
			for(j=1;j<=w;j++) {
				scanf("%c", &buff);
				if(buff=='.') map[j][i] = 1;
				else if(buff=='#') map[j][i] = 0;
				else if(buff=='@') {//
					map[j][i] = 1;
					x=j;
					y=i;
				}//
				else j--;
			}
		}
		
		for(i=0;i<MAX;i++) {
			for(j=0;j<MAX;j++) {
				//printf("%d", map[i][j]);
			}
			//printf("\n");
		}
		count = 0;
		move(x,y);
		
		printf("%d\n", count);
	}
	
	exit(0);
}

void move(int x,int y) {
	if(map[x][y] == 1) {
		map[x][y] = 2;
		count++;
	}
	else return;
	//???
	move(x,y+1);
	//???
	move(x,y-1);
	//???
	move(x-1,y);
	//???
	move(x+1,y);
}