def find_lakes(diagram):
    """Find lakes in diagram.

    >>> pat = str.maketrans('ufd', '/_\\\\')
    >>> find_lakes('ddfuu'.translate(pat))
    [6]
    >>> find_lakes('dduuudfududdddufudduuuffdddfddufdufud'.translate(pat))
    [4, 2, 1, 19, 9]
    >>> find_lakes('ff'.translate(pat))
    []
    """
    def calc_areas(ls):
        areas = []
        e1, e2 = 0, 0
        for n, m in reversed(ls):
            if e1 < n and e2 > m:
                area = areas.pop()
                areas.append(area + (m - n))
            else:
                areas.append(m - n)
                e1, e2 = n, m
        return areas[::-1]

    lakes = []
    slopes = []

    for i, c in enumerate(diagram):
        if c == '\\':
            slopes.append(i)
        elif c == '/':
            if len(slopes) > 0:
                lakes.append((slopes.pop(), i))

    return calc_areas(lakes)


def run():
    ls = find_lakes(input())

    summary = [str(len(ls))] + [str(i) for i in ls]
    print(sum(ls))
    print(" ".join(summary))


if __name__ == '__main__':
    run()
 def find_lakes(diagram):
    """Find lakes in diagram.

    >>> pat = str.maketrans('ufd', '/_\\\\')
    >>> find_lakes('ddfuu'.translate(pat))
    [6]
    >>> find_lakes('dduuudfududdddufudduuuffdddfddufdufud'.translate(pat))
    [4, 2, 1, 19, 9]
    >>> find_lakes('ff'.translate(pat))
    []
    """
    def calc_areas(ls):
        areas = []
        e1, e2 = 0, 0
        for n, m in reversed(ls):
            if e1 < n and e2 > m:
                area = areas.pop()
                areas.append(area + (m - n))
            else:
                areas.append(m - n)
                e1, e2 = n, m
        return areas[::-1]

    lakes = []
    slopes = []

    for i, c in enumerate(diagram):
        if c == '\\':
            slopes.append(i)
        elif c == '/':
            if len(slopes) > 0:
                lakes.append((slopes.pop(), i))

    return calc_areas(lakes) find_lakes """Find lakes in diagram.

    >>> pat = str.maketrans('ufd', '/_\\\\')
    >>> find_lakes('ddfuu'.translate(pat))
    [6]
    >>> find_lakes('dduuudfududdddufudduuuffdddfddufdufud'.translate(pat))
    [4, 2, 1, 19, 9]
    >>> find_lakes('ff'.translate(pat))
    []
    """ def calc_areas(ls):
        areas = []
        e1, e2 = 0, 0
        for n, m in reversed(ls):
            if e1 < n and e2 > m:
                area = areas.pop()
                areas.append(area + (m - n))
            else:
                areas.append(m - n)
                e1, e2 = n, m
        return areas[::-1]

     calc_areas areas = [] areas [] e1, e2 = 0, 0 e1 0 e2 0 for n, m in reversed(ls):
            if e1 < n and e2 > m:
                area = areas.pop()
                areas.append(area + (m - n))
            else:
                areas.append(m - n)
                e1, e2 = n, m
         n m reversed(ls) reversed ls if e1 < n and e2 > m:
                area = areas.pop()
                areas.append(area + (m - n))
            else:
                areas.append(m - n)
                e1, e2 = n, m
         e1 < n and e2 > m e1 < n e1 n e2 > m e2 m area = areas.pop() area areas.pop() areas.pop areas pop areas.append(area + (m - n)) areas.append areas append area + (m - n) area m - n m n areas.append(m - n) areas.append areas append m - n m n e1, e2 = n, m e1 n e2 m return areas[::-1] areas[::-1] areas ::-1 -1 ls ls lakes = [] lakes [] slopes = [] slopes [] for i, c in enumerate(diagram):
        if c == '\\':
            slopes.append(i)
        elif c == '/':
            if len(slopes) > 0:
                lakes.append((slopes.pop(), i))

     i c enumerate(diagram) enumerate diagram if c == '\\':
            slopes.append(i)
        elif c == '/':
            if len(slopes) > 0:
                lakes.append((slopes.pop(), i))

     c == '\\' c '\\' slopes.append(i) slopes.append slopes append i elif c == '/':
            if len(slopes) > 0:
                lakes.append((slopes.pop(), i))

     c == '/' c '/' if len(slopes) > 0:
                lakes.append((slopes.pop(), i))

     len(slopes) > 0 len(slopes) len slopes 0 lakes.append((slopes.pop(), i)) lakes.append lakes append (slopes.pop(), i) slopes.pop() slopes.pop slopes pop i return calc_areas(lakes) calc_areas(lakes) calc_areas lakes diagram diagram def run():
    ls = find_lakes(input())

    summary = [str(len(ls))] + [str(i) for i in ls]
    print(sum(ls))
    print(" ".join(summary)) run ls = find_lakes(input()) ls find_lakes(input()) find_lakes input() input str(i) for i in ls for i in ls i ls for i in ls str(i) str i summary = [str(len(ls))] + [str(i) for i in ls] summary [str(len(ls))] + [str(i) for i in ls] [str(len(ls))] str(len(ls)) str len(ls) len ls [str(i) for i in ls] print(sum(ls)) print sum(ls) sum ls print(" ".join(summary)) print " ".join(summary) " ".join " " join summary if __name__ == '__main__':
    run() __name__ == '__main__' __name__ '__main__' run() run def run():
    ls = find_lakes(input())

    summary = [str(len(ls))] + [str(i) for i in ls]
    print(sum(ls))
    print(" ".join(summary)) def run():
    ls = find_lakes(input())

    summary = [str(len(ls))] + [str(i) for i in ls]
    print(sum(ls))
    print(" ".join(summary)) run def find_lakes(diagram):
    """Find lakes in diagram.

    >>> pat = str.maketrans('ufd', '/_\\\\')
    >>> find_lakes('ddfuu'.translate(pat))
    [6]
    >>> find_lakes('dduuudfududdddufudduuuffdddfddufdufud'.translate(pat))
    [4, 2, 1, 19, 9]
    >>> find_lakes('ff'.translate(pat))
    []
    """
    def calc_areas(ls):
        areas = []
        e1, e2 = 0, 0
        for n, m in reversed(ls):
            if e1 < n and e2 > m:
                area = areas.pop()
                areas.append(area + (m - n))
            else:
                areas.append(m - n)
                e1, e2 = n, m
        return areas[::-1]

    lakes = []
    slopes = []

    for i, c in enumerate(diagram):
        if c == '\\':
            slopes.append(i)
        elif c == '/':
            if len(slopes) > 0:
                lakes.append((slopes.pop(), i))

    return calc_areas(lakes) def find_lakes(diagram):
    """Find lakes in diagram.

    >>> pat = str.maketrans('ufd', '/_\\\\')
    >>> find_lakes('ddfuu'.translate(pat))
    [6]
    >>> find_lakes('dduuudfududdddufudduuuffdddfddufdufud'.translate(pat))
    [4, 2, 1, 19, 9]
    >>> find_lakes('ff'.translate(pat))
    []
    """
    def calc_areas(ls):
        areas = []
        e1, e2 = 0, 0
        for n, m in reversed(ls):
            if e1 < n and e2 > m:
                area = areas.pop()
                areas.append(area + (m - n))
            else:
                areas.append(m - n)
                e1, e2 = n, m
        return areas[::-1]

    lakes = []
    slopes = []

    for i, c in enumerate(diagram):
        if c == '\\':
            slopes.append(i)
        elif c == '/':
            if len(slopes) > 0:
                lakes.append((slopes.pop(), i))

    return calc_areas(lakes) find_lakes
def find_lakes(diagram):
    """Find lakes in diagram.

    >>> pat = str.maketrans('ufd', '/_\\\\')
    >>> find_lakes('ddfuu'.translate(pat))
    [6]
    >>> find_lakes('dduuudfududdddufudduuuffdddfddufdufud'.translate(pat))
    [4, 2, 1, 19, 9]
    >>> find_lakes('ff'.translate(pat))
    []
    """
    def calc_areas(ls):
        areas = []
        e1, e2 = 0, 0
        for n, m in reversed(ls):
            if e1 < n and e2 > m:
                area = areas.pop()
                areas.append(area + (m - n))
            else:
                areas.append(m - n)
                e1, e2 = n, m
        return areas[::-1]

    lakes = []
    slopes = []

    for i, c in enumerate(diagram):
        if c == '\\':
            slopes.append(i)
        elif c == '/':
            if len(slopes) > 0:
                lakes.append((slopes.pop(), i))

    return calc_areas(lakes)


def run():
    ls = find_lakes(input())

    summary = [str(len(ls))] + [str(i) for i in ls]
    print(sum(ls))
    print(" ".join(summary))


if __name__ == '__main__':
    run()

