dfs
import java.util.*;
class Main{
static char a[][];
static int n;
static int m;
static int vis[][];
public static void main(String[] args) {
Scanner in =new Scanner(System.in);
while(in.hasNext()) {
n=in.nextInt();
m=in.nextInt();
if(n==0&&m==0) {
break;
}
int x=0;
int y=0;
a=new char [m][n];
for(int i=0;i<m;i++) {
String s=in.next();
for(int j=0;j<n;j++) {
a[i][j]=s.charAt(j);
if(a[i][j]=='@') {
x=i;
y=j;
}
}
} vis=new int [m][n];
dfs(x,y);
int ans=0;
for(int i=0;i<vis.length;i++) {
for(int j=0;j<n;j++) {
if(vis[i][j]==1) {
ans++;
}
}
}
System.out.println(ans);
}
}
static int dx[]= {0,0,1,-1};
static int dy[]= {1,-1,0,0};
static void dfs(int x,int y) {
vis[x][y]=1;
for(int i=0;i<dx.length;i++) {
int x1=x+dx[i];
int y1=y+dy[i];
if(x1<0||y1<0||x1==m||y1==n) {
continue;
}
if(vis[x1][y1]==0&&a[x1][y1]!='#') {
dfs(x1,y1);
}
}
}
}