#include <bits/stdc++.h>
#define rep(i,x,y) for(int i=x;i<=y;i++)
#define rep1(i,x,y) for(int i=x;i<y;i++)
#define per(i,x,y) for(int i=y;i>=x;i--)
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define _mset(s,_) memset(s,_,sizeof(s));
using namespace std;
int w,h,sx,sy,step;
char a[25][25];
bool vis[25][25];
inline int read(){
int x=0,f=1;
char ch=getchar();
while(ch<'0'||ch>'9'){
if(ch=='-')
f=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9'){
x=(x<<1)+(x<<3)+(ch^48);
ch=getchar();
}
return x*f;
}
void dfs(int x,int y){
if(x<1||y<1||x>h||y>w||vis[x][y]!=0||a[x][y]=='#') return ;
vis[x][y]=1;
step++;
dfs(x-1,y);
dfs(x,y-1);
dfs(x+1,y);
dfs(x,y+1);
}
int main()
{
IOS
w=read();
h=read();
rep(i,1,h){
rep(j,1,w){
cin>>a[i][j];
if(a[i][j]=='@'){
sx=i;sy=j;
}
}
}
dfs(sx,sy);
cout<<step;
return 0;
}