#include <stdio.h>
#define ll long long
#define rep(i,l,r)for(ll i=l;i<r;i++)

//union-find
#define UFLIMIT (1<<17)
int unicnt[UFLIMIT+10];//正ならcnt、非正なら根のindex
void ufinit(int n){rep(i,0,n)unicnt[i]=1;}
int root(int x){return unicnt[x]<=0?-(unicnt[x]=-root(-unicnt[x])):x;}
int same(int x,int y){return root(x)==root(y);}
void uni(int x,int y){if((x=root(x))==(y=root(y)))return;if(unicnt[x]<unicnt[y]){int t=x;x=y;y=t;}unicnt[x]+=unicnt[y];unicnt[y]=-x;}
#undef UFLIMIT

ll d4[]={0,1,0,-1,0};
int main(){
	ll w,h;
	while(scanf("%lld%lld",&w,&h),w){
		char s[30][30]={};
		ufinit(w*h);
		rep(i,1,h+1)scanf(" %s",s[i]+1);
		rep(i,1,h+1)rep(j,1,w+1)if(s[i][j]=='.'||s[i][j]=='@'){
			rep(k,0,4){
				ll ii=i+d4[k];
				ll jj=j+d4[k+1];
				if(s[ii][jj]=='.'||s[ii][jj]=='@')uni((i-1)*w+(j-1),(ii-1)*w+(jj-1));
			}
		}
		rep(i,1,h+1)rep(j,1,w+1)if(s[i][j]=='@')printf("%lld\n",unicnt[root((i-1)*w+(j-1))]);
	}
}
