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

void redbrack(char **a, int x, int y,int m, int h,int *c)
{
  (*c)++;
  a[x][y]='#';
  if(x-1 >= 0){
	if(a[x-1][y] == '.')
		{
			redbrack(a,x-1,y,m,h,c);
		}}
	if(y-1 >= 0){
	if(a[x][y-1] == '.')
		{ 
			redbrack(a,x,y-1,m,h,c);
		}}
	if(x+1 < h){
	if(a[x+1][y] == '.')
		{ 
			redbrack(a,x+1,y,m,h,c);
		}}
	if(y+1 < m){
	if(a[x][y+1] == '.')
		{ 
			redbrack(a,x,y+1,m,h,c);
		}}
}

int main(void)
{

	int i,j,*c;
	char **a;
	int m,h;
	int x,y;
	
	while(1)
		{
			c = (int *)malloc(sizeof(int));
		  *c=0;
			scanf("%d %d ",&m,&h);
			if(m==0 && h==0)break;

			a = (char **)malloc(sizeof(char *)*h);
			for(i=0;i<h;i++){
				a[i]=(char *)malloc(sizeof(char)*m);
			}

			for(i=0;i<h;i++)
				{
					scanf("%s ",a[i]);
					for(j=0;j<m;j++){
					  if(a[i][j]=='@')
								{
									x = i;
									y = j;
								}
						}
				}
		redbrack(a,x,y,m,h,c);
		printf("%d\n",*c);
		}
		
		return 0;
}
		