import collections


def main():
    s = input()
    downs = collections.deque()
    pools = collections.deque()
    total_area = 0
    for now, char in enumerate(s):
        if char == "\\":
            downs.append(now)
        elif downs and char == "/":
            down = downs.pop()
            sub_area = now - down
            total_area += sub_area
            if not pools:
                pools.append((down, sub_area))
            else:
                while pools and down < pools[-1][0]:
                    sub_area += pools.pop()[1]
                pools.append((down, sub_area))
    print(total_area)
    pools = list(zip(*pools))[1] if pools else []
    print(len(pools), *pools)


if __name__ == '__main__':
    main()
 import collections collections def main():
    s = input()
    downs = collections.deque()
    pools = collections.deque()
    total_area = 0
    for now, char in enumerate(s):
        if char == "\\":
            downs.append(now)
        elif downs and char == "/":
            down = downs.pop()
            sub_area = now - down
            total_area += sub_area
            if not pools:
                pools.append((down, sub_area))
            else:
                while pools and down < pools[-1][0]:
                    sub_area += pools.pop()[1]
                pools.append((down, sub_area))
    print(total_area)
    pools = list(zip(*pools))[1] if pools else []
    print(len(pools), *pools) main s = input() s input() input downs = collections.deque() downs collections.deque() collections.deque collections deque pools = collections.deque() pools collections.deque() collections.deque collections deque total_area = 0 total_area 0 for now, char in enumerate(s):
        if char == "\\":
            downs.append(now)
        elif downs and char == "/":
            down = downs.pop()
            sub_area = now - down
            total_area += sub_area
            if not pools:
                pools.append((down, sub_area))
            else:
                while pools and down < pools[-1][0]:
                    sub_area += pools.pop()[1]
                pools.append((down, sub_area))
     now char enumerate(s) enumerate s if char == "\\":
            downs.append(now)
        elif downs and char == "/":
            down = downs.pop()
            sub_area = now - down
            total_area += sub_area
            if not pools:
                pools.append((down, sub_area))
            else:
                while pools and down < pools[-1][0]:
                    sub_area += pools.pop()[1]
                pools.append((down, sub_area))
     char == "\\" char "\\" downs.append(now) downs.append downs append now elif downs and char == "/":
            down = downs.pop()
            sub_area = now - down
            total_area += sub_area
            if not pools:
                pools.append((down, sub_area))
            else:
                while pools and down < pools[-1][0]:
                    sub_area += pools.pop()[1]
                pools.append((down, sub_area))
     downs and char == "/" downs char == "/" char "/" down = downs.pop() down downs.pop() downs.pop downs pop sub_area = now - down sub_area now - down now down total_area += sub_area total_area sub_area if not pools:
                pools.append((down, sub_area))
            else:
                while pools and down < pools[-1][0]:
                    sub_area += pools.pop()[1]
                pools.append((down, sub_area))
     not pools pools pools.append((down, sub_area)) pools.append pools append (down, sub_area) down sub_area while pools and down < pools[-1][0]:
                    sub_area += pools.pop()[1]
                 pools and down < pools[-1][0] pools down < pools[-1][0] down pools[-1][0] [-1] pools -1 0 sub_area += pools.pop()[1] sub_area pools.pop()[1] pools.pop() pools.pop pools pop 1 pools.append((down, sub_area)) pools.append pools append (down, sub_area) down sub_area print(total_area) print total_area pools = list(zip(*pools))[1] if pools else [] pools list(zip(*pools))[1] if pools else [] pools list(zip(*pools))[1] (zip(*pools)) list zip(*pools) zip *pools pools 1 [] print(len(pools), *pools) print len(pools) len pools *pools pools if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    s = input()
    downs = collections.deque()
    pools = collections.deque()
    total_area = 0
    for now, char in enumerate(s):
        if char == "\\":
            downs.append(now)
        elif downs and char == "/":
            down = downs.pop()
            sub_area = now - down
            total_area += sub_area
            if not pools:
                pools.append((down, sub_area))
            else:
                while pools and down < pools[-1][0]:
                    sub_area += pools.pop()[1]
                pools.append((down, sub_area))
    print(total_area)
    pools = list(zip(*pools))[1] if pools else []
    print(len(pools), *pools) def main():
    s = input()
    downs = collections.deque()
    pools = collections.deque()
    total_area = 0
    for now, char in enumerate(s):
        if char == "\\":
            downs.append(now)
        elif downs and char == "/":
            down = downs.pop()
            sub_area = now - down
            total_area += sub_area
            if not pools:
                pools.append((down, sub_area))
            else:
                while pools and down < pools[-1][0]:
                    sub_area += pools.pop()[1]
                pools.append((down, sub_area))
    print(total_area)
    pools = list(zip(*pools))[1] if pools else []
    print(len(pools), *pools) main
import collections


def main():
    s = input()
    downs = collections.deque()
    pools = collections.deque()
    total_area = 0
    for now, char in enumerate(s):
        if char == "\\":
            downs.append(now)
        elif downs and char == "/":
            down = downs.pop()
            sub_area = now - down
            total_area += sub_area
            if not pools:
                pools.append((down, sub_area))
            else:
                while pools and down < pools[-1][0]:
                    sub_area += pools.pop()[1]
                pools.append((down, sub_area))
    print(total_area)
    pools = list(zip(*pools))[1] if pools else []
    print(len(pools), *pools)


if __name__ == '__main__':
    main()

