# coding: utf-8
from collections import deque
input_line = input().strip()
stack1, stack2 = deque(), deque()
for index, i in enumerate(input_line):
    if i == "\\":
        stack1.append(index)
    elif i == "/" and len(stack1) != 0:
        a = stack1.pop()
        #池のマージ
        if len(stack2) != 0 and abs(stack2[-1][0] - a) == 1:
            stack2.append([a, index - a + stack2.pop()[1]])
        else:
            stack2.append([a, index - a])
        #さらにマージ
        while len(stack2) >= 2 and stack2[-1][0] < stack2[-2][0]:
            stack2.append([stack2[-1][0], stack2.pop()[1] + stack2.pop()[1]])
ans = [i[1] for i in stack2]
print(sum(ans))
ans.insert(0, len(ans))
print(*ans) from collections import deque input_line = input().strip() input_line input().strip() ().strip () input strip stack1, stack2 = deque(), deque() stack1 deque() deque stack2 deque() deque for index, i in enumerate(input_line):
    if i == "\\":
        stack1.append(index)
    elif i == "/" and len(stack1) != 0:
        a = stack1.pop()
        #池のマージ
        if len(stack2) != 0 and abs(stack2[-1][0] - a) == 1:
            stack2.append([a, index - a + stack2.pop()[1]])
        else:
            stack2.append([a, index - a])
        #さらにマージ
        while len(stack2) >= 2 and stack2[-1][0] < stack2[-2][0]:
            stack2.append([stack2[-1][0], stack2.pop()[1] + stack2.pop()[1]]) index i enumerate(input_line) enumerate input_line if i == "\\":
        stack1.append(index)
    elif i == "/" and len(stack1) != 0:
        a = stack1.pop()
        #池のマージ
        if len(stack2) != 0 and abs(stack2[-1][0] - a) == 1:
            stack2.append([a, index - a + stack2.pop()[1]])
        else:
            stack2.append([a, index - a])
        #さらにマージ
        while len(stack2) >= 2 and stack2[-1][0] < stack2[-2][0]:
            stack2.append([stack2[-1][0], stack2.pop()[1] + stack2.pop()[1]]) i == "\\" i "\\" stack1.append(index) stack1.append stack1 append index elif i == "/" and len(stack1) != 0:
        a = stack1.pop()
        #池のマージ
        if len(stack2) != 0 and abs(stack2[-1][0] - a) == 1:
            stack2.append([a, index - a + stack2.pop()[1]])
        else:
            stack2.append([a, index - a])
        #さらにマージ
        while len(stack2) >= 2 and stack2[-1][0] < stack2[-2][0]:
            stack2.append([stack2[-1][0], stack2.pop()[1] + stack2.pop()[1]]) i == "/" and len(stack1) != 0 i == "/" i "/" len(stack1) != 0 len(stack1) len stack1 0 a = stack1.pop() a stack1.pop() stack1.pop stack1 pop if len(stack2) != 0 and abs(stack2[-1][0] - a) == 1:
            stack2.append([a, index - a + stack2.pop()[1]])
        else:
            stack2.append([a, index - a])
        #さらにマージ
         len(stack2) != 0 and abs(stack2[-1][0] - a) == 1 len(stack2) != 0 len(stack2) len stack2 0 abs(stack2[-1][0] - a) == 1 abs(stack2[-1][0] - a) abs stack2[-1][0] - a stack2[-1][0] [-1] stack2 -1 0 a 1 stack2.append([a, index - a + stack2.pop()[1]]) stack2.append stack2 append [a, index - a + stack2.pop()[1]] a index - a + stack2.pop()[1] index - a index a stack2.pop()[1] stack2.pop() stack2.pop stack2 pop 1 stack2.append([a, index - a]) stack2.append stack2 append [a, index - a] a index - a index a while len(stack2) >= 2 and stack2[-1][0] < stack2[-2][0]:
            stack2.append([stack2[-1][0], stack2.pop()[1] + stack2.pop()[1]]) len(stack2) >= 2 and stack2[-1][0] < stack2[-2][0] len(stack2) >= 2 len(stack2) len stack2 2 stack2[-1][0] < stack2[-2][0] stack2[-1][0] [-1] stack2 -1 0 stack2[-2][0] [-2] stack2 -2 0 stack2.append([stack2[-1][0], stack2.pop()[1] + stack2.pop()[1]]) stack2.append stack2 append [stack2[-1][0], stack2.pop()[1] + stack2.pop()[1]] stack2[-1][0] [-1] stack2 -1 0 stack2.pop()[1] + stack2.pop()[1] stack2.pop()[1] stack2.pop() stack2.pop stack2 pop 1 stack2.pop()[1] stack2.pop() stack2.pop stack2 pop 1 i[1] for i in stack2 for i in stack2 i stack2 for i in stack2 i[1] i 1 ans = [i[1] for i in stack2] ans [i[1] for i in stack2] print(sum(ans)) print sum(ans) sum ans ans.insert(0, len(ans)) ans.insert ans insert 0 len(ans) len ans print(*ans) print *ans ans a = stack1.pop() stack1.pop() a stack1, stack2 = deque(), deque() deque() stack1 ans = [i[1] for i in stack2] [i[1] for i in stack2] ans stack2 = deque(), deque() deque() stack2 input_line = input().strip() input().strip() input_line
# coding: utf-8
from collections import deque
input_line = input().strip()
stack1, stack2 = deque(), deque()
for index, i in enumerate(input_line):
    if i == "\\":
        stack1.append(index)
    elif i == "/" and len(stack1) != 0:
        a = stack1.pop()
        #池のマージ
        if len(stack2) != 0 and abs(stack2[-1][0] - a) == 1:
            stack2.append([a, index - a + stack2.pop()[1]])
        else:
            stack2.append([a, index - a])
        #さらにマージ
        while len(stack2) >= 2 and stack2[-1][0] < stack2[-2][0]:
            stack2.append([stack2[-1][0], stack2.pop()[1] + stack2.pop()[1]])
ans = [i[1] for i in stack2]
print(sum(ans))
ans.insert(0, len(ans))
print(*ans)