### constant

DXYS = [[1, 0], [0, -1], [-1, 0], [0, 1]]

### main

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

  tls = h.times.map{w.times.map{true}}
  sx = sy = 0

  for y in (0...h)
    line = gets.strip
    for x in (0...w)
      case line[x]
      when '#'
        tls[y][x] = false
      when '@'
        sx = x
        sy = y
      end
    end
  end
  #p tls
  #p [sx, sy]

  visited = h.times.map{w.times.map{false}}
  visited[sy][sx] = true
  count = 1
  q = [[sx, sy]]

  while ! q.empty?
    x, y = q.shift

    DXYS.each do |dx, dy|
      x0 = x + dx
      y0 = y + dy
      if x0 >= 0 && x0 < w && y0 >= 0 && y0 < h &&
          tls[y0][x0] && ! visited[y0][x0]
        visited[y0][x0] = true
        count += 1
        q << [x0, y0]
      end
    end
  end

  puts count
end