#include<stdio.h>
#include<stdlib.h>

int main() {

	char **c;     //?????????
	int W ,H;     //?????????????¨??????¨??????
	int i,j;      //???????????¨?????°
	int a=0;      //??????????´???¨??????????????°
	int count;    //??????
	int flag;     //??¢?´¢????¶?????????????????????????????????°
	int A[10000]; //??????????´???¨??????

	for(;;) {

	scanf("%d %d",&W,&H); //?¨??????¨???????????\???

	if(W==0&&H==0) break;

	c = malloc(sizeof(char *) * H);

	for(i=0;i<H;i++) {
		c[i] = malloc(sizeof(char)*W);
	}

	for(i=0;i<H;i++)
		scanf("%s",c[i]); //??????????????\???

	count=1;
	flag=1;

	while(flag) { //??¢?´¢????§?
		flag = 0;
		for(i=0;i<H;i++) {
			for(j=0;j<W;j++) {
				if(c[i][j]=='@') {
					if(i!=0&&c[i-1][j]=='.') { //???????§????
						count++;
						c[i-1][j]='@';
						flag=1;
					}
					if(j!=W-1&&c[i][j+1]=='.') { //???????§????
						count++;
						c[i][j+1]='@';
						flag=1;
					}
					if(i!=H-1&&c[i+1][j]=='.') { //???????§????
						count++;
						c[i+1][j]='@';
						flag=1;
					}
					if(j!=0&&c[i][j-1]=='.') { //???????§????
						count++;
						c[i][j-1]='@';
						flag=1;
					}
				}
			}
		}
	} //??¢?´¢????¶???????flag??????????¶???????

	A[a]=count;
	a++;

	free(c);
	}

	for(i=0;i<a;i++)
		printf("%d\n",A[i]);

	return 0;
}