#include<iostream>
#include<cstring>
#include<queue>
using namespace std;

struct N
{
	int x,y;
}start,head,tail;

char g[20][20];
int w,h,sum,v[20][20],f[][2]={{-1,0},{0,-1},{1,0},{0,1}};

int bfs()
{
	sum=0;
	memset(v,0,sizeof(v));
	v[start.x][start.y]=1;
	queue<struct N> q;
	q.push(start);
	while(!q.empty())
	{
		sum++;
		head=q.front();
		q.pop();
		for(int i=0;i<4;i++)
		{
			tail.x=head.x+f[i][0];
			tail.y=head.y+f[i][1];
			if(!v[tail.x][tail.y]&&tail.x>=0&&tail.x<h&&tail.y>=0&&tail.y<w&&g[tail.x][tail.y]=='.')
			{
				q.push(tail);
				v[tail.x][tail.y]=1;
			}
		}
	}
	return sum;
}

int main()
{
	int i,j;
	while(cin>>w>>h,w||h)
	{
		for(i=0;i<h;i++)
			for(j=0;j<w;j++)
			{
				cin>>g[i][j];
				if(g[i][j]=='@')
				{
					start.x=i;
					start.y=j;
				}
			}
		cout<<bfs()<<endl;
	}
	return 0;
}
/**************************************************************
	Problem: 2126
	User: admin
	Language: C++
	Result: Accepted
	Time:9 ms
	Memory:2080 kb
****************************************************************/