from collections import deque


def calc_area(chars):
    s1 = deque()
    s2 = deque()
    area = 0

    for idx, char in enumerate(chars):
        if char == "\\":
            s1.append(idx)
        elif char == "/":
            if s1:
                left_idx = s1.pop()
                sub_area = idx - left_idx
                area = area + sub_area
                while s2 and left_idx < s2[-1][0]:
                    sub_area += s2.pop()[1]
                s2.append((left_idx, sub_area))
    return area, s2


def main():
    chars = input()
    area, s2 = calc_area(chars)
    print(area)
    text = ""
    count = 0
    while s2:
        text += " " + str(s2.popleft()[1])
        count += 1
    print(str(count) + text)


if __name__ == "__main__":
    main()
 from collections import deque def calc_area(chars):
    s1 = deque()
    s2 = deque()
    area = 0

    for idx, char in enumerate(chars):
        if char == "\\":
            s1.append(idx)
        elif char == "/":
            if s1:
                left_idx = s1.pop()
                sub_area = idx - left_idx
                area = area + sub_area
                while s2 and left_idx < s2[-1][0]:
                    sub_area += s2.pop()[1]
                s2.append((left_idx, sub_area))
    return area, s2 calc_area s1 = deque() s1 deque() deque s2 = deque() s2 deque() deque area = 0 area 0 for idx, char in enumerate(chars):
        if char == "\\":
            s1.append(idx)
        elif char == "/":
            if s1:
                left_idx = s1.pop()
                sub_area = idx - left_idx
                area = area + sub_area
                while s2 and left_idx < s2[-1][0]:
                    sub_area += s2.pop()[1]
                s2.append((left_idx, sub_area))
     idx char enumerate(chars) enumerate chars if char == "\\":
            s1.append(idx)
        elif char == "/":
            if s1:
                left_idx = s1.pop()
                sub_area = idx - left_idx
                area = area + sub_area
                while s2 and left_idx < s2[-1][0]:
                    sub_area += s2.pop()[1]
                s2.append((left_idx, sub_area))
     char == "\\" char "\\" s1.append(idx) s1.append s1 append idx elif char == "/":
            if s1:
                left_idx = s1.pop()
                sub_area = idx - left_idx
                area = area + sub_area
                while s2 and left_idx < s2[-1][0]:
                    sub_area += s2.pop()[1]
                s2.append((left_idx, sub_area))
     char == "/" char "/" if s1:
                left_idx = s1.pop()
                sub_area = idx - left_idx
                area = area + sub_area
                while s2 and left_idx < s2[-1][0]:
                    sub_area += s2.pop()[1]
                s2.append((left_idx, sub_area))
     s1 left_idx = s1.pop() left_idx s1.pop() s1.pop s1 pop sub_area = idx - left_idx sub_area idx - left_idx idx left_idx area = area + sub_area area area + sub_area area sub_area while s2 and left_idx < s2[-1][0]:
                    sub_area += s2.pop()[1]
                 s2 and left_idx < s2[-1][0] s2 left_idx < s2[-1][0] left_idx s2[-1][0] [-1] s2 -1 0 sub_area += s2.pop()[1] sub_area s2.pop()[1] s2.pop() s2.pop s2 pop 1 s2.append((left_idx, sub_area)) s2.append s2 append (left_idx, sub_area) left_idx sub_area return area, s2 return area, s2 area s2 chars chars def main():
    chars = input()
    area, s2 = calc_area(chars)
    print(area)
    text = ""
    count = 0
    while s2:
        text += " " + str(s2.popleft()[1])
        count += 1
    print(str(count) + text) main chars = input() chars input() input area, s2 = calc_area(chars) area calc_area(chars) calc_area chars s2 print(area) print area text = "" text "" count = 0 count 0 while s2:
        text += " " + str(s2.popleft()[1])
        count += 1
     s2 text += " " + str(s2.popleft()[1]) text " " + str(s2.popleft()[1]) " " str(s2.popleft()[1]) str s2.popleft()[1] s2.popleft() s2.popleft s2 popleft 1 count += 1 count 1 print(str(count) + text) print str(count) + text str(count) str count text if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def calc_area(chars):
    s1 = deque()
    s2 = deque()
    area = 0

    for idx, char in enumerate(chars):
        if char == "\\":
            s1.append(idx)
        elif char == "/":
            if s1:
                left_idx = s1.pop()
                sub_area = idx - left_idx
                area = area + sub_area
                while s2 and left_idx < s2[-1][0]:
                    sub_area += s2.pop()[1]
                s2.append((left_idx, sub_area))
    return area, s2 def calc_area(chars):
    s1 = deque()
    s2 = deque()
    area = 0

    for idx, char in enumerate(chars):
        if char == "\\":
            s1.append(idx)
        elif char == "/":
            if s1:
                left_idx = s1.pop()
                sub_area = idx - left_idx
                area = area + sub_area
                while s2 and left_idx < s2[-1][0]:
                    sub_area += s2.pop()[1]
                s2.append((left_idx, sub_area))
    return area, s2 calc_area def main():
    chars = input()
    area, s2 = calc_area(chars)
    print(area)
    text = ""
    count = 0
    while s2:
        text += " " + str(s2.popleft()[1])
        count += 1
    print(str(count) + text) def main():
    chars = input()
    area, s2 = calc_area(chars)
    print(area)
    text = ""
    count = 0
    while s2:
        text += " " + str(s2.popleft()[1])
        count += 1
    print(str(count) + text) main
from collections import deque


def calc_area(chars):
    s1 = deque()
    s2 = deque()
    area = 0

    for idx, char in enumerate(chars):
        if char == "\\":
            s1.append(idx)
        elif char == "/":
            if s1:
                left_idx = s1.pop()
                sub_area = idx - left_idx
                area = area + sub_area
                while s2 and left_idx < s2[-1][0]:
                    sub_area += s2.pop()[1]
                s2.append((left_idx, sub_area))
    return area, s2


def main():
    chars = input()
    area, s2 = calc_area(chars)
    print(area)
    text = ""
    count = 0
    while s2:
        text += " " + str(s2.popleft()[1])
        count += 1
    print(str(count) + text)


if __name__ == "__main__":
    main()

