#include <iostream>
using namespace std;

int standpanel;
char tile[31][31];

void check(int i,int j)
{
	if(tile[i][j]=='.')
	{
		tile[i][j]='#';
		standpanel++;
		check(i-1,j);
		check(i,j-1);
		check(i+1,j);
		check(i,j+1);
		
	}
	
}


int main(){
	int W,H;
	while(cin>> H >> W &&W&&H)
	{
		standpanel = 0;
		for(int i=0;i<=25;i++)for(int j=0;j<=25;j++)tile[i][j]='#';
		int manx,many;
		for(int i=1;i<=W;i++)for(int j=1;j<=H;j++)
		{
			cin >> tile[i][j];
			if(tile[i][j]=='@'){manx = i;many = j;tile[i][j]='.';}
			
		}
		check(manx,many);
		cout << standpanel << endl;
	}
	return 0;
}