#include<bits/stdc++.h>
using namespace std;
int n,m,maxi = -1e9;
char a[25][25];
bool vis[25][25];
int dx[] = {0,1,0,-1};
int dy[] = {1,0,-1,0};
void dfs(int x,int y,int sum){
bool use = 0;
for(int i = 0;i <= 3;i ++){
int nx = x + dx[i];
int ny = y + dy[i];
if(nx >= 1 && ny >= 1 && ny <= m && nx <= n && vis[nx][ny] == 0 && a[nx][ny] == '.')
{
vis[nx][ny] = true;
dfs(nx,ny,sum + 1);
use = 1;
}
}
if(use == 0){
maxi = max(maxi,sum);
return ;
}
return ;
}
int main()
{
int x,y;
cin >> m >> n;
for(int i = 1;i <= n;i ++)
for(int j = 1;j <= m;j ++){
cin >> a[i][j];
if(a[i][j] == '@')
x = i,y = j;
}
dfs(x,y,1);
cout << maxi;
return 0;
}