#include<bits/stdc++.h>
using namespace std;
int weight,tx,ty,i,j,high,fx,fy,jishu=-1;
char dt[21][21];
int dis[4][2]={0,0,-1,1,-1,1,0,0};
int dfs(int hx,int hy,int step){
dt[hx][hy]='#';
for(i=0;i<4;i++){
jishu=max(jishu,step);
tx=dis[i][0]+hx;
ty=dis[i][1]+hy;
if(ty<=weight&&ty>0&&tx<=high&&tx>0&&dt[tx][ty]=='.'){
step++;
dfs(tx,ty,step);
}
}
}
int main(){
scanf("%d%d",&weight,&high);
for(i=1;i<=weight;i++)
for(j=1;j<=high;j++){
scanf("%s",&dt[i][j]);
if(dt[i][j]=='@'){
fx=i;fy=j;
}
}
dfs(fx,fy,1);
printf("%d",jishu);
return 0;
}