#include<iostream>
using namespace std;
int n, m;
char a[10086][10086];
bool bj[10086][10086] = {0};
int cs_h, cs_l;
int cnt = 0;
void dfs(int h, int l)
{
if(h < 1 || h > m || l < 1 || l > n
|| a[h][l] == '#'
|| bj[h][l] == 1)
{
return;
}
bj[h][l] = 1;
cnt++;
dfs(h + 1, l);
dfs(h - 1, l);
dfs(h, l - 1);
dfs(h, l + 1);
}
int main()
{
cin >> n >> m;
for(int i = 1; i <= m; i++)
{
for(int j = 1; j <= n; j++)
{
cin >> a[i][j];
if(a[i][j] == '@')
{
cs_h = m;
cs_l = n;
}
}
}
dfs(cs_h, cs_l);
cout << cnt;
return 0;
}