#include<bits/stdc++.h>
#define x first
#define y second
using namespace std;
const int N = 25;
int n, m, cnt;
char a[N][N];
bool st[N][N];
int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};
void print()
{
for(int i = 0; i < m; i ++)
{
for(int j = 0; j < n; j ++)
cout << a[i][j];
cout << endl;
}
}
void bfs(int x, int y)
{
queue<pair<int, int>> q;
q.push({x, y});
st[x][y] = true;
cnt ++;
while(q.size())
{
auto t = q.front();
q.pop();
for(int i = 0; i < 4; i ++)
{
int xx = t.x + dx[i], yy = t.y + dy[i];
if(xx >= 0 && xx < m && yy >= 0 && yy < n && a[xx][yy] != '#')
{
if(!st[xx][yy])
{
cnt ++;
q.push({xx, yy});
st[xx][yy] = true;
}
}
}
}
}
int main()
{
while(cin >> n >> m, n && m)
{
memset(st, 0, sizeof st);
int x, y;
for(int i = 0; i < m; i ++)
for(int j = 0; j < n; j ++)
{
cin >> a[i][j];
if(a[i][j] == '@')
{
x = i;
y = j;
}
}
cnt = 0;
bfs(x, y);
cout << cnt << endl;
}
return 0;
}