from collections import deque
area = input()
S1 = deque()
S2 = deque()
total = 0

for i, v in enumerate(area):
    if v == '\\':
        S1.append(i)
    elif v == '/' and S1:
        j = S1.pop()
        subtotal = i - j
        total += i - j
        while S2 and S2[-1][0] > j:
            subtotal += S2.pop()[1]
        S2.append([j, subtotal])

print(total)
print(len(S2), *(subtotal for j, subtotal in S2)) from collections import deque area = input() area input() input S1 = deque() S1 deque() deque S2 = deque() S2 deque() deque total = 0 total 0 for i, v in enumerate(area):
    if v == '\\':
        S1.append(i)
    elif v == '/' and S1:
        j = S1.pop()
        subtotal = i - j
        total += i - j
        while S2 and S2[-1][0] > j:
            subtotal += S2.pop()[1]
        S2.append([j, subtotal]) i v enumerate(area) enumerate area if v == '\\':
        S1.append(i)
    elif v == '/' and S1:
        j = S1.pop()
        subtotal = i - j
        total += i - j
        while S2 and S2[-1][0] > j:
            subtotal += S2.pop()[1]
        S2.append([j, subtotal]) v == '\\' v '\\' S1.append(i) S1.append S1 append i elif v == '/' and S1:
        j = S1.pop()
        subtotal = i - j
        total += i - j
        while S2 and S2[-1][0] > j:
            subtotal += S2.pop()[1]
        S2.append([j, subtotal]) v == '/' and S1 v == '/' v '/' S1 j = S1.pop() j S1.pop() S1.pop S1 pop subtotal = i - j subtotal i - j i j total += i - j total i - j i j while S2 and S2[-1][0] > j:
            subtotal += S2.pop()[1]
         S2 and S2[-1][0] > j S2 S2[-1][0] > j S2[-1][0] [-1] S2 -1 0 j subtotal += S2.pop()[1] subtotal S2.pop()[1] S2.pop() S2.pop S2 pop 1 S2.append([j, subtotal]) S2.append S2 append [j, subtotal] j subtotal print(total) print total subtotal for j, subtotal in S2 for j, subtotal in S2 j subtotal S2 for j, subtotal in S2 subtotal print(len(S2), *(subtotal for j, subtotal in S2)) print len(S2) len S2 *(subtotal for j, subtotal in S2) (subtotal for j, subtotal in S2) total += i - j i - j total j = S1.pop() S1.pop() j subtotal += S2.pop()[1] S2.pop()[1] subtotal subtotal = i - j i - j subtotal S1 = deque() deque() S1 total = 0 0 total area = input() input() area S2 = deque() deque() S2
from collections import deque
area = input()
S1 = deque()
S2 = deque()
total = 0

for i, v in enumerate(area):
    if v == '\\':
        S1.append(i)
    elif v == '/' and S1:
        j = S1.pop()
        subtotal = i - j
        total += i - j
        while S2 and S2[-1][0] > j:
            subtotal += S2.pop()[1]
        S2.append([j, subtotal])

print(total)
print(len(S2), *(subtotal for j, subtotal in S2))