from collections import deque
input_list = list(input())

left_idx_stack = deque()
puddle_stack = deque()

for idx, s in enumerate(input_list):
    if s == "\\":
        left_idx_stack.append(idx)
    
    elif s == '/':
        if left_idx_stack:
            latest_left_idx = left_idx_stack.pop()
            area = idx - latest_left_idx
        
            if not puddle_stack:
                puddle_stack.append((latest_left_idx, area))
            
            elif latest_left_idx > puddle_stack[-1][0]:
                puddle_stack.append((latest_left_idx, area))
            else:
                
                while len(puddle_stack) != 0 and (latest_left_idx < puddle_stack[-1][0]):
                    latest_puddle = puddle_stack.pop()
                    area += latest_puddle[1]
                    
                puddle_stack.append((latest_left_idx, area))
        else:
            pass
areas = [p[1] for p in puddle_stack]
print(sum(areas))
print(len(areas), *areas)
 from collections import deque input_list = list(input()) input_list list(input()) list input() input left_idx_stack = deque() left_idx_stack deque() deque puddle_stack = deque() puddle_stack deque() deque for idx, s in enumerate(input_list):
    if s == "\\":
        left_idx_stack.append(idx)
    
    elif s == '/':
        if left_idx_stack:
            latest_left_idx = left_idx_stack.pop()
            area = idx - latest_left_idx
        
            if not puddle_stack:
                puddle_stack.append((latest_left_idx, area))
            
            elif latest_left_idx > puddle_stack[-1][0]:
                puddle_stack.append((latest_left_idx, area))
            else:
                
                while len(puddle_stack) != 0 and (latest_left_idx < puddle_stack[-1][0]):
                    latest_puddle = puddle_stack.pop()
                    area += latest_puddle[1]
                    
                puddle_stack.append((latest_left_idx, area))
        else:
            pass idx s enumerate(input_list) enumerate input_list if s == "\\":
        left_idx_stack.append(idx)
    
    elif s == '/':
        if left_idx_stack:
            latest_left_idx = left_idx_stack.pop()
            area = idx - latest_left_idx
        
            if not puddle_stack:
                puddle_stack.append((latest_left_idx, area))
            
            elif latest_left_idx > puddle_stack[-1][0]:
                puddle_stack.append((latest_left_idx, area))
            else:
                
                while len(puddle_stack) != 0 and (latest_left_idx < puddle_stack[-1][0]):
                    latest_puddle = puddle_stack.pop()
                    area += latest_puddle[1]
                    
                puddle_stack.append((latest_left_idx, area))
        else:
            pass s == "\\" s "\\" left_idx_stack.append(idx) left_idx_stack.append left_idx_stack append idx elif s == '/':
        if left_idx_stack:
            latest_left_idx = left_idx_stack.pop()
            area = idx - latest_left_idx
        
            if not puddle_stack:
                puddle_stack.append((latest_left_idx, area))
            
            elif latest_left_idx > puddle_stack[-1][0]:
                puddle_stack.append((latest_left_idx, area))
            else:
                
                while len(puddle_stack) != 0 and (latest_left_idx < puddle_stack[-1][0]):
                    latest_puddle = puddle_stack.pop()
                    area += latest_puddle[1]
                    
                puddle_stack.append((latest_left_idx, area))
        else:
            pass s == '/' s '/' if left_idx_stack:
            latest_left_idx = left_idx_stack.pop()
            area = idx - latest_left_idx
        
            if not puddle_stack:
                puddle_stack.append((latest_left_idx, area))
            
            elif latest_left_idx > puddle_stack[-1][0]:
                puddle_stack.append((latest_left_idx, area))
            else:
                
                while len(puddle_stack) != 0 and (latest_left_idx < puddle_stack[-1][0]):
                    latest_puddle = puddle_stack.pop()
                    area += latest_puddle[1]
                    
                puddle_stack.append((latest_left_idx, area))
        else:
            pass left_idx_stack latest_left_idx = left_idx_stack.pop() latest_left_idx left_idx_stack.pop() left_idx_stack.pop left_idx_stack pop area = idx - latest_left_idx area idx - latest_left_idx idx latest_left_idx if not puddle_stack:
                puddle_stack.append((latest_left_idx, area))
            
            elif latest_left_idx > puddle_stack[-1][0]:
                puddle_stack.append((latest_left_idx, area))
            else:
                
                while len(puddle_stack) != 0 and (latest_left_idx < puddle_stack[-1][0]):
                    latest_puddle = puddle_stack.pop()
                    area += latest_puddle[1]
                    
                puddle_stack.append((latest_left_idx, area))
         not puddle_stack puddle_stack puddle_stack.append((latest_left_idx, area)) puddle_stack.append puddle_stack append (latest_left_idx, area) latest_left_idx area elif latest_left_idx > puddle_stack[-1][0]:
                puddle_stack.append((latest_left_idx, area))
             latest_left_idx > puddle_stack[-1][0] latest_left_idx puddle_stack[-1][0] [-1] puddle_stack -1 0 puddle_stack.append((latest_left_idx, area)) puddle_stack.append puddle_stack append (latest_left_idx, area) latest_left_idx area while len(puddle_stack) != 0 and (latest_left_idx < puddle_stack[-1][0]):
                    latest_puddle = puddle_stack.pop()
                    area += latest_puddle[1]
                    
                 len(puddle_stack) != 0 and (latest_left_idx < puddle_stack[-1][0]) len(puddle_stack) != 0 len(puddle_stack) len puddle_stack 0 latest_left_idx < puddle_stack[-1][0] latest_left_idx puddle_stack[-1][0] [-1] puddle_stack -1 0 latest_puddle = puddle_stack.pop() latest_puddle puddle_stack.pop() puddle_stack.pop puddle_stack pop area += latest_puddle[1] area latest_puddle[1] latest_puddle 1 puddle_stack.append((latest_left_idx, area)) puddle_stack.append puddle_stack append (latest_left_idx, area) latest_left_idx area p[1] for p in puddle_stack for p in puddle_stack p puddle_stack for p in puddle_stack p[1] p 1 areas = [p[1] for p in puddle_stack] areas [p[1] for p in puddle_stack] print(sum(areas)) print sum(areas) sum areas print(len(areas), *areas) print len(areas) len areas *areas areas left_idx_stack = deque() deque() left_idx_stack latest_left_idx = left_idx_stack.pop() left_idx_stack.pop() latest_left_idx input_list = list(input()) list(input()) input_list latest_puddle = puddle_stack.pop() puddle_stack.pop() latest_puddle puddle_stack = deque() deque() puddle_stack area = idx - latest_left_idx idx - latest_left_idx area area += latest_puddle[1] latest_puddle[1] area areas = [p[1] for p in puddle_stack] [p[1] for p in puddle_stack] areas
from collections import deque
input_list = list(input())

left_idx_stack = deque()
puddle_stack = deque()

for idx, s in enumerate(input_list):
    if s == "\\":
        left_idx_stack.append(idx)
    
    elif s == '/':
        if left_idx_stack:
            latest_left_idx = left_idx_stack.pop()
            area = idx - latest_left_idx
        
            if not puddle_stack:
                puddle_stack.append((latest_left_idx, area))
            
            elif latest_left_idx > puddle_stack[-1][0]:
                puddle_stack.append((latest_left_idx, area))
            else:
                
                while len(puddle_stack) != 0 and (latest_left_idx < puddle_stack[-1][0]):
                    latest_puddle = puddle_stack.pop()
                    area += latest_puddle[1]
                    
                puddle_stack.append((latest_left_idx, area))
        else:
            pass
areas = [p[1] for p in puddle_stack]
print(sum(areas))
print(len(areas), *areas)

