#include<stdio.h>
struct pos{
int x;
int y;
};
struct pos que[10010];
int move[4][2]={{0,1},{0,-1},{1,0},{-1,0}};
char bfs[25][25];
int book[25][25];
int maxn;
int count=1;
int main(){
int w,h,head,tail;
scanf("%d %d",&w,&h);
for(int i=0;i<h;i++)
for(int j=0;j<w;j++)
scanf(" %c",&bfs[i][j]);
for(int i=0;i<h;i++)
for(int j=0;j<w;j++)
{
if(bfs[i][j]=='@'){
book[i][j]=1;
que[0].x=i;
que[0].y=j;
}
}
tail++;
while(head<tail){
for(int i=0;i<4;i++){
if(book[que[head].x+move[i][0]][que[head].y+move[i][1]]==1){
continue;
}
if(bfs[que[head].x+move[i][0]][que[head].y+move[i][1]]=='#'){
continue;
}
if(que[head].x+move[i][0]>=0&&que[head].x+move[i][0]<h&&que[head].y+move[i][1]>=0&&que[head].y+move[i][1]<w){
que[tail].x=que[head].x+move[i][0];
que[tail].y=que[head].y+move[i][1];
book[que[tail].x][que[tail].y]=1;
count++;
tail++;
}
}
head++;
}
printf("%d\n",count);
return 0;
}