#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int maxn =25,maxm = 25;
int n,m,ans;
string map[maxn];
bool visited[maxn][maxm];
void search(int row, int col){
if(row<0||row>n||col<0||col>m||map[row][col]=='#'||visited[row][col])
return;
visited[row][col] = true;
++ans;
search(row-1,col);
search(row+1,col);
search(row,col-1);
search(row,col+1);
}
int main() {
cin >> m >> n;
while(n||m){
int row,col;
for(int i=0;i<n;i++){
cin>>map[i];
for(int j=0;j<m;j++)
if(map[i][j]=='@'){
row = i;
col = j;
}
}
memset(visited,false,sizeof(visited));
ans=0;
search(row,col);
cout << ans << endl;
cin >> m >> n;
}
return 0;
}