#include<bits/stdc++.h>
using namespace std;
int w, h, ans;
char g[25][25];
bool st[25][25];
int dx[4] = { -1,0,1,0 }, dy[4] = { 0,1,0,-1 };
void dfs(int x, int y)
{
for (int i = 0; i < 4; i++)
{
int a = x + dx[i];
int b = y + dy[i];
if (a<1 || a>h || b<1 || b>w)
continue;
if (g[a][b] == '#')
continue;
if (st[a][b])
continue;
st[a][b] = true;
ans++;
dfs(a, b);
}
}
int main() {
scanf("%d%d", &w, &h);
for (int i = 1; i <= h; i++)
{
getchar();
for (int j = 1; j <= w; j++)
{
scanf("%c", &g[i][j]);
}
}
for (int i = 1; i <= h; i++)
{
for (int j = 1; j <= w; j++)
{
if (g[i][j] == '@')
{
st[i][j] = true;
dfs(i, j);
break;
}
}
}
ans++;
printf("%d", ans);
return 0;
}