#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
using namespace std;
int W, H;
const int inf = 0x3f3f3f3f;
int map[25][25], vis[25][25];
int sx, sy;
int dir[4][2] = {0, 1, 1, 0, 0, -1, -1, 0};
int ans;
void dfs(int x, int y) {
int i;
for(i = 0; i < 4; i++) {
int tx = x + dir[i][0];
int ty = y + dir[i][1];
if(tx >= 0 && ty >= 0 && tx <= H - 1 && ty <= W - 1) {
if(map[tx][ty] == '.') {
map[tx][ty] = '#';
ans++;
dfs(tx, ty);
}
}
}
}
int main() {
while(~scanf("%d %d", &W, &H) && W + H) {
getchar();
int i, j;
for(i = 0; i < H; i++) {
for(j = 0; j < W; j++) {
scanf("%c", &map[i][j]);
if(map[i][j] == '@') sx = i, sy = j;
}
getchar();
}
ans = 1;
map[sx][sy] = '#';
dfs(sx, sy);
printf("%d\n", ans);
}
return 0;
}