from collections import deque

codes = input()

s1 = deque([])
s2 = deque([])

sums = 0
for idx1, ch in enumerate(codes):
    if ch == '\\':
        s1.append(idx1)
    elif ch == '/' and len(s1) > 0:
        idx2 = s1.pop()
        area = idx1 - idx2
        sums += area
        while len(s2) > 0 and s2[-1][0] > idx2:
            area += s2.pop()[1]
        s2.append([idx2, area])

output = []
while len(s2) > 0:
    output.append(s2.pop()[1])
output.reverse()
print(sum(output))
output.insert(0, len(output))
print(" ".join(map(str, output))) from collections import deque codes = input() codes input() input s1 = deque([]) s1 deque([]) deque [] s2 = deque([]) s2 deque([]) deque [] sums = 0 sums 0 for idx1, ch in enumerate(codes):
    if ch == '\\':
        s1.append(idx1)
    elif ch == '/' and len(s1) > 0:
        idx2 = s1.pop()
        area = idx1 - idx2
        sums += area
        while len(s2) > 0 and s2[-1][0] > idx2:
            area += s2.pop()[1]
        s2.append([idx2, area]) idx1 ch enumerate(codes) enumerate codes if ch == '\\':
        s1.append(idx1)
    elif ch == '/' and len(s1) > 0:
        idx2 = s1.pop()
        area = idx1 - idx2
        sums += area
        while len(s2) > 0 and s2[-1][0] > idx2:
            area += s2.pop()[1]
        s2.append([idx2, area]) ch == '\\' ch '\\' s1.append(idx1) s1.append s1 append idx1 elif ch == '/' and len(s1) > 0:
        idx2 = s1.pop()
        area = idx1 - idx2
        sums += area
        while len(s2) > 0 and s2[-1][0] > idx2:
            area += s2.pop()[1]
        s2.append([idx2, area]) ch == '/' and len(s1) > 0 ch == '/' ch '/' len(s1) > 0 len(s1) len s1 0 idx2 = s1.pop() idx2 s1.pop() s1.pop s1 pop area = idx1 - idx2 area idx1 - idx2 idx1 idx2 sums += area sums area while len(s2) > 0 and s2[-1][0] > idx2:
            area += s2.pop()[1]
         len(s2) > 0 and s2[-1][0] > idx2 len(s2) > 0 len(s2) len s2 0 s2[-1][0] > idx2 s2[-1][0] [-1] s2 -1 0 idx2 area += s2.pop()[1] area s2.pop()[1] s2.pop() s2.pop s2 pop 1 s2.append([idx2, area]) s2.append s2 append [idx2, area] idx2 area output = [] output [] while len(s2) > 0:
    output.append(s2.pop()[1]) len(s2) > 0 len(s2) len s2 0 output.append(s2.pop()[1]) output.append output append s2.pop()[1] s2.pop() s2.pop s2 pop 1 output.reverse() output.reverse output reverse print(sum(output)) print sum(output) sum output output.insert(0, len(output)) output.insert output insert 0 len(output) len output print(" ".join(map(str, output))) print " ".join(map(str, output)) " ".join " " join map(str, output) map str output idx2 = s1.pop() s1.pop() idx2 area = idx1 - idx2 idx1 - idx2 area sums += area area sums area += s2.pop()[1] s2.pop()[1] area output = [] [] output codes = input() input() codes s1 = deque([]) deque([]) s1 s2 = deque([]) deque([]) s2 sums = 0 0 sums
from collections import deque

codes = input()

s1 = deque([])
s2 = deque([])

sums = 0
for idx1, ch in enumerate(codes):
    if ch == '\\':
        s1.append(idx1)
    elif ch == '/' and len(s1) > 0:
        idx2 = s1.pop()
        area = idx1 - idx2
        sums += area
        while len(s2) > 0 and s2[-1][0] > idx2:
            area += s2.pop()[1]
        s2.append([idx2, area])

output = []
while len(s2) > 0:
    output.append(s2.pop()[1])
output.reverse()
print(sum(output))
output.insert(0, len(output))
print(" ".join(map(str, output)))
