current = 0
walls = {}
total = 0
ponds = []
gets.split('').each.with_index do |c, i|
  case c
  when '\\'
    walls[current] = i
    current -= 1
  when '/'
    current += 1
    start =  walls[current]
    if start
      total += i - start
      subponds = ponds.select {|pond| pond[0] > start }
      if subponds.empty?
        ponds << [start, (i - start)]
      else
        ponds -= subponds
        ponds << [start, (i - start) + subponds.map {|sp| sp[1]}.reduce(&:+)]
      end
    end
  when '_'
  when "\n"
    break
  end
end
puts total
ponds = [ponds.size] + ponds.map {|p| p[1]}
puts ponds.join(' ')

