# coding: utf-8

def areas_calc(strings):
    stack1 = []
    stack2 = []
    total_m = 0
    for i, s in enumerate(strings):
        if s == "\\":
            stack1.append(i)
        elif s == "_":
            continue
        elif s == '/':
            if len(stack1) > 0:
                previous_i = stack1.pop()
                m = i - previous_i
                total_m += m

                while len(stack2) > 0:
                    stacked_i, stacked_m = stack2.pop()
                    if previous_i < stacked_i:
                        m += stacked_m
                    else:
                        stack2.append((stacked_i, stacked_m))
                        stack2.append((previous_i, m))
                        break

                else:
                    stack2.append((previous_i, m))
    print(total_m)
    k = len(stack2)
    for_output = [str(k)] + [str(m) for i, m in stack2]
    print(' '.join(for_output))
    

if __name__ == "__main__":
    areas_calc(input())
 def areas_calc(strings):
    stack1 = []
    stack2 = []
    total_m = 0
    for i, s in enumerate(strings):
        if s == "\\":
            stack1.append(i)
        elif s == "_":
            continue
        elif s == '/':
            if len(stack1) > 0:
                previous_i = stack1.pop()
                m = i - previous_i
                total_m += m

                while len(stack2) > 0:
                    stacked_i, stacked_m = stack2.pop()
                    if previous_i < stacked_i:
                        m += stacked_m
                    else:
                        stack2.append((stacked_i, stacked_m))
                        stack2.append((previous_i, m))
                        break

                else:
                    stack2.append((previous_i, m))
    print(total_m)
    k = len(stack2)
    for_output = [str(k)] + [str(m) for i, m in stack2]
    print(' '.join(for_output))
     areas_calc stack1 = [] stack1 [] stack2 = [] stack2 [] total_m = 0 total_m 0 for i, s in enumerate(strings):
        if s == "\\":
            stack1.append(i)
        elif s == "_":
            continue
        elif s == '/':
            if len(stack1) > 0:
                previous_i = stack1.pop()
                m = i - previous_i
                total_m += m

                while len(stack2) > 0:
                    stacked_i, stacked_m = stack2.pop()
                    if previous_i < stacked_i:
                        m += stacked_m
                    else:
                        stack2.append((stacked_i, stacked_m))
                        stack2.append((previous_i, m))
                        break

                else:
                    stack2.append((previous_i, m))
     i s enumerate(strings) enumerate strings if s == "\\":
            stack1.append(i)
        elif s == "_":
            continue
        elif s == '/':
            if len(stack1) > 0:
                previous_i = stack1.pop()
                m = i - previous_i
                total_m += m

                while len(stack2) > 0:
                    stacked_i, stacked_m = stack2.pop()
                    if previous_i < stacked_i:
                        m += stacked_m
                    else:
                        stack2.append((stacked_i, stacked_m))
                        stack2.append((previous_i, m))
                        break

                else:
                    stack2.append((previous_i, m))
     s == "\\" s "\\" stack1.append(i) stack1.append stack1 append i elif s == "_":
            continue
         s == "_" s "_" continue elif s == '/':
            if len(stack1) > 0:
                previous_i = stack1.pop()
                m = i - previous_i
                total_m += m

                while len(stack2) > 0:
                    stacked_i, stacked_m = stack2.pop()
                    if previous_i < stacked_i:
                        m += stacked_m
                    else:
                        stack2.append((stacked_i, stacked_m))
                        stack2.append((previous_i, m))
                        break

                else:
                    stack2.append((previous_i, m))
     s == '/' s '/' if len(stack1) > 0:
                previous_i = stack1.pop()
                m = i - previous_i
                total_m += m

                while len(stack2) > 0:
                    stacked_i, stacked_m = stack2.pop()
                    if previous_i < stacked_i:
                        m += stacked_m
                    else:
                        stack2.append((stacked_i, stacked_m))
                        stack2.append((previous_i, m))
                        break

                else:
                    stack2.append((previous_i, m))
     len(stack1) > 0 len(stack1) len stack1 0 previous_i = stack1.pop() previous_i stack1.pop() stack1.pop stack1 pop m = i - previous_i m i - previous_i i previous_i total_m += m total_m m while len(stack2) > 0:
                    stacked_i, stacked_m = stack2.pop()
                    if previous_i < stacked_i:
                        m += stacked_m
                    else:
                        stack2.append((stacked_i, stacked_m))
                        stack2.append((previous_i, m))
                        break

                else:
                    stack2.append((previous_i, m))
     len(stack2) > 0 len(stack2) len stack2 0 stacked_i, stacked_m = stack2.pop() stacked_i stack2.pop() stack2.pop stack2 pop stacked_m if previous_i < stacked_i:
                        m += stacked_m
                    else:
                        stack2.append((stacked_i, stacked_m))
                        stack2.append((previous_i, m))
                        break

                 previous_i < stacked_i previous_i stacked_i m += stacked_m m stacked_m stack2.append((stacked_i, stacked_m)) stack2.append stack2 append (stacked_i, stacked_m) stacked_i stacked_m stack2.append((previous_i, m)) stack2.append stack2 append (previous_i, m) previous_i m break stack2.append((previous_i, m)) stack2.append stack2 append (previous_i, m) previous_i m print(total_m) print total_m k = len(stack2) k len(stack2) len stack2 str(m) for i, m in stack2 for i, m in stack2 i m stack2 for i, m in stack2 str(m) str m for_output = [str(k)] + [str(m) for i, m in stack2] for_output [str(k)] + [str(m) for i, m in stack2] [str(k)] str(k) str k [str(m) for i, m in stack2] print(' '.join(for_output)) print ' '.join(for_output) ' '.join ' ' join for_output strings strings if __name__ == "__main__":
    areas_calc(input()) __name__ == "__main__" __name__ "__main__" areas_calc(input()) areas_calc input() input def areas_calc(strings):
    stack1 = []
    stack2 = []
    total_m = 0
    for i, s in enumerate(strings):
        if s == "\\":
            stack1.append(i)
        elif s == "_":
            continue
        elif s == '/':
            if len(stack1) > 0:
                previous_i = stack1.pop()
                m = i - previous_i
                total_m += m

                while len(stack2) > 0:
                    stacked_i, stacked_m = stack2.pop()
                    if previous_i < stacked_i:
                        m += stacked_m
                    else:
                        stack2.append((stacked_i, stacked_m))
                        stack2.append((previous_i, m))
                        break

                else:
                    stack2.append((previous_i, m))
    print(total_m)
    k = len(stack2)
    for_output = [str(k)] + [str(m) for i, m in stack2]
    print(' '.join(for_output))
     def areas_calc(strings):
    stack1 = []
    stack2 = []
    total_m = 0
    for i, s in enumerate(strings):
        if s == "\\":
            stack1.append(i)
        elif s == "_":
            continue
        elif s == '/':
            if len(stack1) > 0:
                previous_i = stack1.pop()
                m = i - previous_i
                total_m += m

                while len(stack2) > 0:
                    stacked_i, stacked_m = stack2.pop()
                    if previous_i < stacked_i:
                        m += stacked_m
                    else:
                        stack2.append((stacked_i, stacked_m))
                        stack2.append((previous_i, m))
                        break

                else:
                    stack2.append((previous_i, m))
    print(total_m)
    k = len(stack2)
    for_output = [str(k)] + [str(m) for i, m in stack2]
    print(' '.join(for_output))
     areas_calc
# coding: utf-8

def areas_calc(strings):
    stack1 = []
    stack2 = []
    total_m = 0
    for i, s in enumerate(strings):
        if s == "\\":
            stack1.append(i)
        elif s == "_":
            continue
        elif s == '/':
            if len(stack1) > 0:
                previous_i = stack1.pop()
                m = i - previous_i
                total_m += m

                while len(stack2) > 0:
                    stacked_i, stacked_m = stack2.pop()
                    if previous_i < stacked_i:
                        m += stacked_m
                    else:
                        stack2.append((stacked_i, stacked_m))
                        stack2.append((previous_i, m))
                        break

                else:
                    stack2.append((previous_i, m))
    print(total_m)
    k = len(stack2)
    for_output = [str(k)] + [str(m) for i, m in stack2]
    print(' '.join(for_output))
    

if __name__ == "__main__":
    areas_calc(input())

