# frozen_string_literal: true

land = gets
downs = []
lakes = []
land.chars.each.with_index do |c, i|
  case c
  when '\\'
    downs.push(i)
  when '/'
    area = 0
    next unless downs.any?

    new_shore = downs.pop
    while lakes.any? && lakes.last[0] > new_shore
      point = lakes.pop
      area += point[1]
    end
    area += i - new_shore
    lakes.push([i, area])
  end
end
results = lakes.map { |l| l[1] }
puts results.sum
results.unshift(results.count)
puts results.join(' ')

