#include <stdio.h>
#include <string.h>

#define N 32

static char d[ N ][ N ];
static int  w, h;

static int
solve (
  int x,
  int y
  )
{
  int res = 1;

  if ( ( x < 0 && x >= w )
    || ( y < 0 && y >= h )
    || d[ y ][ x ] != '.' ) return ( 0 );

  d[ y ][ x ] = '#';
  res += solve ( x - 1, y );
  res += solve ( x + 1, y );
  res += solve ( x, y - 1 );
  res += solve ( x, y + 1 );

  return ( res );
}

/** Application main entry point. */
int
main (
  int     argc,
  char  * argv[ ]
  )
{
  int i;

  for ( ; ; )
  {
    int sx, sy;

    scanf ( " %d %d", &w, &h );
    if ( !( w | h ) ) break ;

    for ( i = 0; i < h; ++i )
    {
      char * v;

      scanf ( " %s", d[ i ] );

      v = strchr ( d[ i ], '@' );
      if ( v != NULL )
      {
        sx = v - d[ i ];
        sy = i;
        *v = '.';
      }
    }

    printf ( "%d\n", solve ( sx, sy ) );
  }

  return ( 0 );
}