#include <stdio.h>
#include <ctype.h>

#define N 20;

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

static
int dfs (
  int x,
  int y
  )
{
  int res;

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

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

  return ( res );
}

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  for ( ; ; )
  {
    int sx = 0, sy = 0;
    int x, y;

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

    for ( y = 0; y < h; ++y )
    for ( x = 0; x < w; ++x )
    {
      int ch = ' ';

      while ( isspace ( ch ) )  ch = getchar ( );
      if ( ch == '@' )
      {
        sx = x; sy = y;
        d[ x ][ y ] = '.';
      }
      else
      {
        d[ x ][ y ] = ch;
      }
    }

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

  return ( 0 );
}