#include "iostream"
using namespace std;

char a[20][20];

int main()
{
	int w,h;
	int b,c;
	
	int z=0;
	while(1)
	{
		int i,j;
		cin>>w>>h;
		if(w==0&&h==0)break;
		for(i=0;i<w;i++)
			for(j=0;j<h;j++)
			{
				cin>>a[i][j];
				if(a[i][j]=='@')
				{
					b=i;
					c=j;
				}
			}
			for(i=b;i<w;i++)
				for(j=c;j<h;j++)
				{
					if(a[i][j]!='@'&&a[i][j]!='#'&&(a[i-1][j]=='@'||a[i][j-1]=='@'))
					{
						a[i][j]='@';
						z++;
						
					}
				}
				for(i=b;i<w;i++)
					for(j=c;j>=0;j--)
					{
						if(a[i][j]!='@'&&a[i][j]!='#'&&(a[i-1][j]=='@'||a[i][j+1]=='@'))
						{
							a[i][j]='@';
							z++;
						}
					}
				for(i=b;i>=0;i--)
					for(j=c;j>=0;j--)
					{
						if(a[i][j]!='@'&&a[i][j]!='#'&&(a[i+1][j]=='@'||a[i][j+1]=='@'))
						{
							a[i][j]='@';
						    z++;
						}
					}
				for(i=b;i>=0;i--)
					for(j=c;j<h;j++)
					{
						if(a[i][j]!='@'&&a[i][j]!='#'&&(a[i][j-1]=='@'||a[i+1][j]=='@'))
						{
							a[i][j]='@';
							z++;
						}
					}
					
					cout<<z<<endl;
    
	}
	return 0;
}