#include <bits/stdc++.h>
using namespace std;
int n, m, sx, sy, ans;
char c[25][25];
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
bool vis[25][25];
void DFS(int x, int y)
{
if(x < 1 || y < 1 || x > n || y > m)return;
if(c[x][y] == '#')return;
if(vis[x][y])return;
vis[x][y] = true;
for(int i = 0; i < 4; i++)
{
DFS(x + dx[i], y + dy[i]);
}
}
int main()
{
scanf("%d%d", &m, &n);
for(int i = 1; i <= n; i++)
{
for(int j = 1; j <= m; j++)
{
cin >> c[i][j];
if(c[i][j] == '@')sx = i, sy = j;
}
}
DFS(sx, sy);
printf("%d", ans);
return 0;
}