from collections import deque
from sys import stdin

A = input()
d = deque([])
e = deque([])
area = 0
areas = deque([])

for a,b in enumerate(A):
    if b == "\\":
        d.append(a)
    elif b == "/" and d != deque([]):
        x = d.pop()
        area += a - x
        areas.append([x,a,a-x])

menseki = 0
kaitou = []
prev_start,prev_end = 20000,0
while len(areas) > 0:
    temp = areas.pop()
    if temp[0] > prev_start and temp[1] < prev_end:
        menseki += temp[2]
    else:
        if menseki != 0:
            kaitou.append(menseki)
        menseki = temp[2]
        prev_start, prev_end = temp[0],temp[1]
    if len(areas) == 0:
        kaitou.append(menseki)

print(sum(kaitou))
kaitou.append(len(kaitou))
print(*kaitou[::-1])
 from collections import deque from sys import stdin A = input() A input() input d = deque([]) d deque([]) deque [] e = deque([]) e deque([]) deque [] area = 0 area 0 areas = deque([]) areas deque([]) deque [] for a,b in enumerate(A):
    if b == "\\":
        d.append(a)
    elif b == "/" and d != deque([]):
        x = d.pop()
        area += a - x
        areas.append([x,a,a-x]) a b enumerate(A) enumerate A if b == "\\":
        d.append(a)
    elif b == "/" and d != deque([]):
        x = d.pop()
        area += a - x
        areas.append([x,a,a-x]) b == "\\" b "\\" d.append(a) d.append d append a elif b == "/" and d != deque([]):
        x = d.pop()
        area += a - x
        areas.append([x,a,a-x]) b == "/" and d != deque([]) b == "/" b "/" d != deque([]) d deque([]) deque [] x = d.pop() x d.pop() d.pop d pop area += a - x area a - x a x areas.append([x,a,a-x]) areas.append areas append [x,a,a-x] x a a-x a x menseki = 0 menseki 0 kaitou = [] kaitou [] prev_start,prev_end = 20000,0 prev_start 20000 prev_end 0 while len(areas) > 0:
    temp = areas.pop()
    if temp[0] > prev_start and temp[1] < prev_end:
        menseki += temp[2]
    else:
        if menseki != 0:
            kaitou.append(menseki)
        menseki = temp[2]
        prev_start, prev_end = temp[0],temp[1]
    if len(areas) == 0:
        kaitou.append(menseki) len(areas) > 0 len(areas) len areas 0 temp = areas.pop() temp areas.pop() areas.pop areas pop if temp[0] > prev_start and temp[1] < prev_end:
        menseki += temp[2]
    else:
        if menseki != 0:
            kaitou.append(menseki)
        menseki = temp[2]
        prev_start, prev_end = temp[0],temp[1]
     temp[0] > prev_start and temp[1] < prev_end temp[0] > prev_start temp[0] temp 0 prev_start temp[1] < prev_end temp[1] temp 1 prev_end menseki += temp[2] menseki temp[2] temp 2 if menseki != 0:
            kaitou.append(menseki)
         menseki != 0 menseki 0 kaitou.append(menseki) kaitou.append kaitou append menseki menseki = temp[2] menseki temp[2] temp 2 prev_start, prev_end = temp[0],temp[1] prev_start temp[0] temp 0 prev_end temp[1] temp 1 if len(areas) == 0:
        kaitou.append(menseki) len(areas) == 0 len(areas) len areas 0 kaitou.append(menseki) kaitou.append kaitou append menseki print(sum(kaitou)) print sum(kaitou) sum kaitou kaitou.append(len(kaitou)) kaitou.append kaitou append len(kaitou) len kaitou print(*kaitou[::-1]) print *kaitou[::-1] kaitou[::-1] kaitou ::-1 -1 areas = deque([]) deque([]) areas kaitou = [] [] kaitou A = input() input() A area = 0 0 area menseki = 0 0 menseki temp = areas.pop() areas.pop() temp prev_end = 20000,0 0 prev_end prev_end = temp[0],temp[1] temp[1] prev_end prev_start,prev_end = 20000,0 20000 prev_start menseki = temp[2] temp[2] menseki x = d.pop() d.pop() x area += a - x a - x area menseki += temp[2] temp[2] menseki e = deque([]) deque([]) e d = deque([]) deque([]) d prev_start, prev_end = temp[0],temp[1] temp[0] prev_start
from collections import deque
from sys import stdin

A = input()
d = deque([])
e = deque([])
area = 0
areas = deque([])

for a,b in enumerate(A):
    if b == "\\":
        d.append(a)
    elif b == "/" and d != deque([]):
        x = d.pop()
        area += a - x
        areas.append([x,a,a-x])

menseki = 0
kaitou = []
prev_start,prev_end = 20000,0
while len(areas) > 0:
    temp = areas.pop()
    if temp[0] > prev_start and temp[1] < prev_end:
        menseki += temp[2]
    else:
        if menseki != 0:
            kaitou.append(menseki)
        menseki = temp[2]
        prev_start, prev_end = temp[0],temp[1]
    if len(areas) == 0:
        kaitou.append(menseki)

print(sum(kaitou))
kaitou.append(len(kaitou))
print(*kaitou[::-1])

