from collections import deque

S = input()


s1 = deque()
s2 = deque()
total = 0

for i, s in enumerate(S):
    if s == '\\':
        s1.append(i)
    elif s == '/':
        if not s1:
            continue
        j = s1.pop()
        total += i - j

        vol = i - j
        while s2 and s2[-1][0] >= j:
            vol += s2.pop()[1]

        s2.append((j, vol))

print(total)
print(len(s2), *[vol for idx, vol in s2])
 from collections import deque S = input() S input() input s1 = deque() s1 deque() deque s2 = deque() s2 deque() deque total = 0 total 0 for i, s in enumerate(S):
    if s == '\\':
        s1.append(i)
    elif s == '/':
        if not s1:
            continue
        j = s1.pop()
        total += i - j

        vol = i - j
        while s2 and s2[-1][0] >= j:
            vol += s2.pop()[1]

        s2.append((j, vol)) i s enumerate(S) enumerate S if s == '\\':
        s1.append(i)
    elif s == '/':
        if not s1:
            continue
        j = s1.pop()
        total += i - j

        vol = i - j
        while s2 and s2[-1][0] >= j:
            vol += s2.pop()[1]

        s2.append((j, vol)) s == '\\' s '\\' s1.append(i) s1.append s1 append i elif s == '/':
        if not s1:
            continue
        j = s1.pop()
        total += i - j

        vol = i - j
        while s2 and s2[-1][0] >= j:
            vol += s2.pop()[1]

        s2.append((j, vol)) s == '/' s '/' if not s1:
            continue
         not s1 s1 continue j = s1.pop() j s1.pop() s1.pop s1 pop total += i - j total i - j i j vol = i - j vol i - j i j while s2 and s2[-1][0] >= j:
            vol += s2.pop()[1]

         s2 and s2[-1][0] >= j s2 s2[-1][0] >= j s2[-1][0] [-1] s2 -1 0 j vol += s2.pop()[1] vol s2.pop()[1] s2.pop() s2.pop s2 pop 1 s2.append((j, vol)) s2.append s2 append (j, vol) j vol print(total) print total vol for idx, vol in s2 for idx, vol in s2 idx vol s2 for idx, vol in s2 vol print(len(s2), *[vol for idx, vol in s2]) print len(s2) len s2 *[vol for idx, vol in s2] [vol for idx, vol in s2] total = 0 0 total s1 = deque() deque() s1 total += i - j i - j total vol = i - j i - j vol S = input() input() S j = s1.pop() s1.pop() j s2 = deque() deque() s2 vol += s2.pop()[1] s2.pop()[1] vol
from collections import deque

S = input()


s1 = deque()
s2 = deque()
total = 0

for i, s in enumerate(S):
    if s == '\\':
        s1.append(i)
    elif s == '/':
        if not s1:
            continue
        j = s1.pop()
        total += i - j

        vol = i - j
        while s2 and s2[-1][0] >= j:
            vol += s2.pop()[1]

        s2.append((j, vol))

print(total)
print(len(s2), *[vol for idx, vol in s2])

