#include <bits/stdc++.h>
using namespace std;
int n, m;
char a[105][105];
bool vis[105][105] = {};
int dx[8]{ 0,1,0,-1,-1,1,1,-1 };
int dy[8]{ -1,0,1,0,-1,1,-1,1 };
int sum = 0;
int xx, yy;
void dfs(int x, int y) {
for (int i = 0; i < 4; i++) {
int xx = x + dx[i];
int yy = y + dy[i];//记录新位置
if (vis[xx][yy] == 0 && xx >= 1 && yy >= 1 && xx <= m && yy <= n && a[xx][yy] != '#') {
vis[xx][yy] = 1;
sum++;
dfs(xx, yy);
}
}
}
int main() {
while (cin >> m >> n) {
if (n == 0 && m == 0) {
break;
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
cin >> a[i][j];
}
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if (a[i][j] == '@') {
dfs(i, j);
break;
}
}
}
cout << sum << endl;
sum = 0;
vis[105][105]={};
}
return 0;
}
#include <bits/stdc++.h>
using namespace std;
int n, m;
char a[105][105];
bool vis[105][105] = {};
int dx[8]{ 0,1,0,-1,-1,1,1,-1 };
int dy[8]{ -1,0,1,0,-1,1,-1,1 };
int sum = 0;
int xx, yy;
void dfs(int x, int y) {
for (int i = 0; i < 4; i++) {
int xx = x + dx[i];
int yy = y + dy[i];//记录新位置
if (vis[xx][yy] == 0 && xx >= 1 && yy >= 1 && xx <= n && yy <= m && a[xx][yy] != '#') {
vis[xx][yy] = 1;
sum++;
dfs(xx, yy);
}
}
}
int main() {
while (cin >> m >> n) {
if (n == 0 && m == 0) {
break;
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
cin >> a[i][j];
}
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if (a[i][j] == '@') {
dfs(i, j);
break;
}
}
}
cout << sum << endl;
}
return 0;
}