import queue

inpstr = input()
stack = queue.LifoQueue()
stack_areas = queue.LifoQueue()

cnt = 0  # 位置
area = 0  # 総面積
for s in inpstr:
	if s == '\\':
		stack.put(cnt)
	elif s == '/':
		if not stack.empty():
			i = stack.get()
			area = area + cnt - i
			# 個々の面積の再計算
			temp = [i, cnt - i]  # 今回の面積と開始位置
			if stack_areas.empty():
				stack_areas.put(temp)
			else:
				for j in range(0, stack_areas.qsize()):
					temp2 = stack_areas.get()
					if i > temp2[0]:
						stack_areas.put(temp2)
						break
					else:
						temp[1] = temp[1] + temp2[1]
				stack_areas.put(temp)
	elif s == '_':
		pass  # 何もしない、結果cntだけ増える
	cnt = cnt + 1

print(area)
# stackから出力用のリストに変換
areas = []
while not stack_areas.empty():
	areas.append(stack_areas.get()[1])
#print(areas)
areas.append(len(areas))
areas.reverse()
print(' '.join([str(n) for n in areas]))
 import queue queue inpstr = input() inpstr input() input stack = queue.LifoQueue() stack queue.LifoQueue() queue.LifoQueue queue LifoQueue stack_areas = queue.LifoQueue() stack_areas queue.LifoQueue() queue.LifoQueue queue LifoQueue cnt = 0 cnt 0 area = 0 area 0 for s in inpstr:
	if s == '\\':
		stack.put(cnt)
	elif s == '/':
		if not stack.empty():
			i = stack.get()
			area = area + cnt - i
			# 個々の面積の再計算
			temp = [i, cnt - i]  # 今回の面積と開始位置
			if stack_areas.empty():
				stack_areas.put(temp)
			else:
				for j in range(0, stack_areas.qsize()):
					temp2 = stack_areas.get()
					if i > temp2[0]:
						stack_areas.put(temp2)
						break
					else:
						temp[1] = temp[1] + temp2[1]
				stack_areas.put(temp)
	elif s == '_':
		pass  # 何もしない、結果cntだけ増える
	cnt = cnt + 1 s inpstr if s == '\\':
		stack.put(cnt)
	elif s == '/':
		if not stack.empty():
			i = stack.get()
			area = area + cnt - i
			# 個々の面積の再計算
			temp = [i, cnt - i]  # 今回の面積と開始位置
			if stack_areas.empty():
				stack_areas.put(temp)
			else:
				for j in range(0, stack_areas.qsize()):
					temp2 = stack_areas.get()
					if i > temp2[0]:
						stack_areas.put(temp2)
						break
					else:
						temp[1] = temp[1] + temp2[1]
				stack_areas.put(temp)
	elif s == '_':
		pass  # 何もしない、結果cntだけ増える
	 s == '\\' s '\\' stack.put(cnt) stack.put stack put cnt elif s == '/':
		if not stack.empty():
			i = stack.get()
			area = area + cnt - i
			# 個々の面積の再計算
			temp = [i, cnt - i]  # 今回の面積と開始位置
			if stack_areas.empty():
				stack_areas.put(temp)
			else:
				for j in range(0, stack_areas.qsize()):
					temp2 = stack_areas.get()
					if i > temp2[0]:
						stack_areas.put(temp2)
						break
					else:
						temp[1] = temp[1] + temp2[1]
				stack_areas.put(temp)
	 s == '/' s '/' if not stack.empty():
			i = stack.get()
			area = area + cnt - i
			# 個々の面積の再計算
			temp = [i, cnt - i]  # 今回の面積と開始位置
			if stack_areas.empty():
				stack_areas.put(temp)
			else:
				for j in range(0, stack_areas.qsize()):
					temp2 = stack_areas.get()
					if i > temp2[0]:
						stack_areas.put(temp2)
						break
					else:
						temp[1] = temp[1] + temp2[1]
				stack_areas.put(temp)
	 not stack.empty() stack.empty() stack.empty stack empty i = stack.get() i stack.get() stack.get stack get area = area + cnt - i area area + cnt - i area + cnt area cnt i temp = [i, cnt - i] temp [i, cnt - i] i cnt - i cnt i if stack_areas.empty():
				stack_areas.put(temp)
			else:
				for j in range(0, stack_areas.qsize()):
					temp2 = stack_areas.get()
					if i > temp2[0]:
						stack_areas.put(temp2)
						break
					else:
						temp[1] = temp[1] + temp2[1]
				stack_areas.put(temp)
	 stack_areas.empty() stack_areas.empty stack_areas empty stack_areas.put(temp) stack_areas.put stack_areas put temp for j in range(0, stack_areas.qsize()):
					temp2 = stack_areas.get()
					if i > temp2[0]:
						stack_areas.put(temp2)
						break
					else:
						temp[1] = temp[1] + temp2[1]
				 j range(0, stack_areas.qsize()) range 0 stack_areas.qsize() stack_areas.qsize stack_areas qsize temp2 = stack_areas.get() temp2 stack_areas.get() stack_areas.get stack_areas get if i > temp2[0]:
						stack_areas.put(temp2)
						break
					else:
						temp[1] = temp[1] + temp2[1]
				 i > temp2[0] i temp2[0] temp2 0 stack_areas.put(temp2) stack_areas.put stack_areas put temp2 break temp[1] = temp[1] + temp2[1] temp[1] temp 1 temp[1] + temp2[1] temp[1] temp 1 temp2[1] temp2 1 stack_areas.put(temp) stack_areas.put stack_areas put temp elif s == '_':
		pass  # 何もしない、結果cntだけ増える
	 s == '_' s '_' cnt = cnt + 1 cnt cnt + 1 cnt 1 print(area) print area areas = [] areas [] while not stack_areas.empty():
	areas.append(stack_areas.get()[1])
#print(areas) not stack_areas.empty() stack_areas.empty() stack_areas.empty stack_areas empty areas.append(stack_areas.get()[1]) areas.append areas append stack_areas.get()[1] stack_areas.get() stack_areas.get stack_areas get 1 areas.append(len(areas)) areas.append areas append len(areas) len areas areas.reverse() areas.reverse areas reverse str(n) for n in areas for n in areas n areas for n in areas str(n) str n print(' '.join([str(n) for n in areas])) print ' '.join([str(n) for n in areas]) ' '.join ' ' join [str(n) for n in areas] temp2 = stack_areas.get() stack_areas.get() temp2 cnt = cnt + 1 cnt + 1 cnt stack_areas = queue.LifoQueue() queue.LifoQueue() stack_areas cnt = 0 0 cnt areas = [] [] areas temp = [i, cnt - i] [i, cnt - i] temp i = stack.get() stack.get() i stack = queue.LifoQueue() queue.LifoQueue() stack inpstr = input() input() inpstr area = area + cnt - i area + cnt - i area area = 0 0 area
import queue

inpstr = input()
stack = queue.LifoQueue()
stack_areas = queue.LifoQueue()

cnt = 0  # 位置
area = 0  # 総面積
for s in inpstr:
	if s == '\\':
		stack.put(cnt)
	elif s == '/':
		if not stack.empty():
			i = stack.get()
			area = area + cnt - i
			# 個々の面積の再計算
			temp = [i, cnt - i]  # 今回の面積と開始位置
			if stack_areas.empty():
				stack_areas.put(temp)
			else:
				for j in range(0, stack_areas.qsize()):
					temp2 = stack_areas.get()
					if i > temp2[0]:
						stack_areas.put(temp2)
						break
					else:
						temp[1] = temp[1] + temp2[1]
				stack_areas.put(temp)
	elif s == '_':
		pass  # 何もしない、結果cntだけ増える
	cnt = cnt + 1

print(area)
# stackから出力用のリストに変換
areas = []
while not stack_areas.empty():
	areas.append(stack_areas.get()[1])
#print(areas)
areas.append(len(areas))
areas.reverse()
print(' '.join([str(n) for n in areas]))

