#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstring>

using namespace std;

const int MAXN=30;
int vis[MAXN][MAXN];
char maze[MAXN][MAXN];
int sx,sy;
int counter;

void DFS(int x,int y)
{
    if(vis[x][y] || maze[x][y]=='#')return;
    vis[x][y]=1;
    counter++;
    DFS(x-1,y);
    DFS(x,y-1);
    DFS(x+1,y);
    DFS(x,y+1);
}

int main()
{
    //cout << "Hello world!" << endl;


    freopen("input","r",stdin);
    int w,h;
    while(scanf("%d %d",&w,&h)==2)
    {
        memset(vis,0,sizeof(vis));
        memset(maze,'#',sizeof(maze));
        counter=0;
        if(w==0 || h==0)break;
        for(int i=1;i<=h;i++)
        {
            for(int j=1;j<=w;j++)
            {
                cin>>maze[i][j];
                if(maze[i][j]=='@')
                {
                    sx=i;
                    sy=j;
                }
            }
        }
        //
        /*
        cout<<endl<<endl;
        for(int i=0;i<=h+1;i++)
        {
            for(int j=0;j<=w+1;j++)
            {
                cout<<maze[i][j]<<" ";
            }
            cout<<endl;
        }
        */
        DFS(sx,sy);
        cout<<counter<<endl;
    }
    fclose(stdin);
    return 0;
}