loop do
  w, h = gets.split.map(&:to_i)
  break if h == 0

  field = h.times.map do
    gets.chomp.split(//)
  end


  i, j = -> () {
    field.each.with_index do |f, i|
      f.each.with_index do |c, j|
        return [i,j] if c == '@'
      end
    end
  }.()

  field[i][j] = '.'

  walk = -> (x, y) {
    return 0 if x < 0 || y < 0 || x >= h || y >= w
    return 0 if field[x][y] != '.'
    field[x][y] = 'x'
    return 1 + 
      walk.(x+1, y) +
      walk.(x-1, y) +
      walk.(x, y-1) +
      walk.(x, y+1)
  }

  cnt = walk.(i, j)

  puts cnt
end