#include<bits/stdc++.h>
using namespace std;
int w,h,ans=1;
bool flag[101][101];
char a[30][30];
int fx[5]={0,0,1,0,-1};
int fy[5]={0,1,0,-1,0};
void dfs(int x,int y){
int tx,ty;
for(int i=1;i<=4;i++){
tx=x+fx[i];
ty=y+fy[i];
if(a[tx][ty]=='.'&&flag[tx][ty]!=true){
flag[tx][ty]=true;
ans++;
dfs(tx,ty);
}
}
}
int main() {
int qx,qy;
cin>>w>>h;
for(int i=1;i<=w;i++){
for(int j=1;j<=h;j++){
a[i][j]=0;
}
}
for(int i=1;i<=w;i++){
for(int j=1;j<=h;j++){
cin>>a[i][j];
if(a[i][j]=='@'){
qx=i;
qy=j;
}
}
}
dfs(qx,qy);
cout<<ans;
return 0;
}