
class Stack:
    def __init__(self, data=None):
        # Pythonではクラスのデフォルト引数は１度しか初期化されないため、
        # うっかりdata=[]としてしまうと、複数のインスタンスを生成したときに
        # 同じ配列を参照することになってしまう！！！
        # http://amacbee.hatenablog.com/entry/2016/12/07/004510
        if data is None:
            self.data = []
        else:
            self.data = data

    def push(self, x):
        self.data.append(x)

    def pop(self):
        if self.is_empty() is True:
            return None
        else:
            return self.data.pop(-1)

    def is_empty(self):
        if len(self.data) == 0:
            return True
        else:
            return False

    def get_length(self):
        return len(self.data)

    def reverse(self):
        self.data.reverse()


# \\//
# \\///\_/\/\\\\/_/\\///__\\\_\\/_\/_/\

diagram = input()
A = 0  # 総面積
k = 0  # 水たまりの数
L = []  # 各水たまりの面積

s1 = Stack()
s2 = Stack()

new_flood = False

# s1.push(10)
# s1.push(20)
# s1.push(30)
# print(s2.data)

for i, vector in enumerate(diagram):
    # print('----------')
    # print(i, vector)

    if vector == '\\':
        # print('下り')
        # print('test')
        s1.push(i)

        # 個別
        # data = {'first_pos': i, 'area': 0}
        # s2.push(data)
        # grad = 'down'

        new_flood = True

    elif vector == '/':
        # print('上り')
        j = s1.pop()
        if j is not None:
            # print(i, j)
            A += i - j

            # current_flood = s2.pop()
            # if current_flood['first_pos'] =
            # Agenshidan88
            # = i:
            #     current_flood['area'] += i - j

            size = i - j

            if new_flood is True:
                s2.push({'first_pos': j, 'size': size})
                new_flood = False

            # if s2.is_empty() is True:
            #     s2.push({'first_pos': j, 'area': i-j})

            else:
                current_flood = s2.pop()
                current_flood['first_pos'] = j
                current_flood['size'] += size

                while True:
                    prev_flood = s2.pop()
                    if prev_flood is not None:
                        if prev_flood['first_pos'] > j:
                            current_flood['size'] += prev_flood['size']
                        else:
                            s2.push(prev_flood)
                            s2.push(current_flood)
                            break
                    else:
                        s2.push(current_flood)
                        break

    # print(s1.data)
    # print(s2.data)
    # print('----------')

print(A)

output = str(s2.get_length())
for elem in s2.data:
    output += ' ' + str(elem['size'])

print(output)
 class Stack:
    def __init__(self, data=None):
        # Pythonではクラスのデフォルト引数は１度しか初期化されないため、
        # うっかりdata=[]としてしまうと、複数のインスタンスを生成したときに
        # 同じ配列を参照することになってしまう！！！
        # http://amacbee.hatenablog.com/entry/2016/12/07/004510
        if data is None:
            self.data = []
        else:
            self.data = data

    def push(self, x):
        self.data.append(x)

    def pop(self):
        if self.is_empty() is True:
            return None
        else:
            return self.data.pop(-1)

    def is_empty(self):
        if len(self.data) == 0:
            return True
        else:
            return False

    def get_length(self):
        return len(self.data)

    def reverse(self):
        self.data.reverse()


# \\//
# \\///\_/\/\\\\/_/\\///__\\\_\\/_\/_/\ Stack def __init__(self, data=None):
        # Pythonではクラスのデフォルト引数は１度しか初期化されないため、
        # うっかりdata=[]としてしまうと、複数のインスタンスを生成したときに
        # 同じ配列を参照することになってしまう！！！
        # http://amacbee.hatenablog.com/entry/2016/12/07/004510
        if data is None:
            self.data = []
        else:
            self.data = data

     __init__ if data is None:
            self.data = []
        else:
            self.data = data

     data is None data None self.data = [] self.data self data [] self.data = data self.data self data data self self data=None data None def push(self, x):
        self.data.append(x)

     push self.data.append(x) self.data.append self.data self data append x self self x x def pop(self):
        if self.is_empty() is True:
            return None
        else:
            return self.data.pop(-1)

     pop if self.is_empty() is True:
            return None
        else:
            return self.data.pop(-1)

     self.is_empty() is True self.is_empty() self.is_empty self is_empty True return None None return self.data.pop(-1) self.data.pop(-1) self.data.pop self.data self data pop -1 self self def is_empty(self):
        if len(self.data) == 0:
            return True
        else:
            return False

     is_empty if len(self.data) == 0:
            return True
        else:
            return False

     len(self.data) == 0 len(self.data) len self.data self data 0 return True True return False False self self def get_length(self):
        return len(self.data)

     get_length return len(self.data) len(self.data) len self.data self data self self def reverse(self):
        self.data.reverse()


# \\//
# \\///\_/\/\\\\/_/\\///__\\\_\\/_\/_/\ reverse self.data.reverse() self.data.reverse self.data self data reverse self self diagram = input() diagram input() input A = 0 A 0 k = 0 k 0 L = [] L [] s1 = Stack() s1 Stack() Stack s2 = Stack() s2 Stack() Stack new_flood = False new_flood False for i, vector in enumerate(diagram):
    # print('----------')
    # print(i, vector)

    if vector == '\\':
        # print('下り')
        # print('test')
        s1.push(i)

        # 個別
        # data = {'first_pos': i, 'area': 0}
        # s2.push(data)
        # grad = 'down'

        new_flood = True

    elif vector == '/':
        # print('上り')
        j = s1.pop()
        if j is not None:
            # print(i, j)
            A += i - j

            # current_flood = s2.pop()
            # if current_flood['first_pos'] =
            # Agenshidan88
            # = i:
            #     current_flood['area'] += i - j

            size = i - j

            if new_flood is True:
                s2.push({'first_pos': j, 'size': size})
                new_flood = False

            # if s2.is_empty() is True:
            #     s2.push({'first_pos': j, 'area': i-j})

            else:
                current_flood = s2.pop()
                current_flood['first_pos'] = j
                current_flood['size'] += size

                while True:
                    prev_flood = s2.pop()
                    if prev_flood is not None:
                        if prev_flood['first_pos'] > j:
                            current_flood['size'] += prev_flood['size']
                        else:
                            s2.push(prev_flood)
                            s2.push(current_flood)
                            break
                    else:
                        s2.push(current_flood)
                        break

    # print(s1.data)
    # print(s2.data)
    # print('----------') i vector enumerate(diagram) enumerate diagram if vector == '\\':
        # print('下り')
        # print('test')
        s1.push(i)

        # 個別
        # data = {'first_pos': i, 'area': 0}
        # s2.push(data)
        # grad = 'down'

        new_flood = True

    elif vector == '/':
        # print('上り')
        j = s1.pop()
        if j is not None:
            # print(i, j)
            A += i - j

            # current_flood = s2.pop()
            # if current_flood['first_pos'] =
            # Agenshidan88
            # = i:
            #     current_flood['area'] += i - j

            size = i - j

            if new_flood is True:
                s2.push({'first_pos': j, 'size': size})
                new_flood = False

            # if s2.is_empty() is True:
            #     s2.push({'first_pos': j, 'area': i-j})

            else:
                current_flood = s2.pop()
                current_flood['first_pos'] = j
                current_flood['size'] += size

                while True:
                    prev_flood = s2.pop()
                    if prev_flood is not None:
                        if prev_flood['first_pos'] > j:
                            current_flood['size'] += prev_flood['size']
                        else:
                            s2.push(prev_flood)
                            s2.push(current_flood)
                            break
                    else:
                        s2.push(current_flood)
                        break

    # print(s1.data)
    # print(s2.data)
    # print('----------') vector == '\\' vector '\\' s1.push(i) s1.push s1 push i new_flood = True new_flood True elif vector == '/':
        # print('上り')
        j = s1.pop()
        if j is not None:
            # print(i, j)
            A += i - j

            # current_flood = s2.pop()
            # if current_flood['first_pos'] =
            # Agenshidan88
            # = i:
            #     current_flood['area'] += i - j

            size = i - j

            if new_flood is True:
                s2.push({'first_pos': j, 'size': size})
                new_flood = False

            # if s2.is_empty() is True:
            #     s2.push({'first_pos': j, 'area': i-j})

            else:
                current_flood = s2.pop()
                current_flood['first_pos'] = j
                current_flood['size'] += size

                while True:
                    prev_flood = s2.pop()
                    if prev_flood is not None:
                        if prev_flood['first_pos'] > j:
                            current_flood['size'] += prev_flood['size']
                        else:
                            s2.push(prev_flood)
                            s2.push(current_flood)
                            break
                    else:
                        s2.push(current_flood)
                        break

    # print(s1.data)
    # print(s2.data)
    # print('----------') vector == '/' vector '/' j = s1.pop() j s1.pop() s1.pop s1 pop if j is not None:
            # print(i, j)
            A += i - j

            # current_flood = s2.pop()
            # if current_flood['first_pos'] =
            # Agenshidan88
            # = i:
            #     current_flood['area'] += i - j

            size = i - j

            if new_flood is True:
                s2.push({'first_pos': j, 'size': size})
                new_flood = False

            # if s2.is_empty() is True:
            #     s2.push({'first_pos': j, 'area': i-j})

            else:
                current_flood = s2.pop()
                current_flood['first_pos'] = j
                current_flood['size'] += size

                while True:
                    prev_flood = s2.pop()
                    if prev_flood is not None:
                        if prev_flood['first_pos'] > j:
                            current_flood['size'] += prev_flood['size']
                        else:
                            s2.push(prev_flood)
                            s2.push(current_flood)
                            break
                    else:
                        s2.push(current_flood)
                        break

    # print(s1.data)
    # print(s2.data)
    # print('----------') j is not None j None A += i - j A i - j i j size = i - j size i - j i j if new_flood is True:
                s2.push({'first_pos': j, 'size': size})
                new_flood = False

            # if s2.is_empty() is True:
            #     s2.push({'first_pos': j, 'area': i-j})

            else:
                current_flood = s2.pop()
                current_flood['first_pos'] = j
                current_flood['size'] += size

                while True:
                    prev_flood = s2.pop()
                    if prev_flood is not None:
                        if prev_flood['first_pos'] > j:
                            current_flood['size'] += prev_flood['size']
                        else:
                            s2.push(prev_flood)
                            s2.push(current_flood)
                            break
                    else:
                        s2.push(current_flood)
                        break

    # print(s1.data)
    # print(s2.data)
    # print('----------') new_flood is True new_flood True s2.push({'first_pos': j, 'size': size}) s2.push s2 push {'first_pos': j, 'size': size} 'first_pos' 'first_pos' j 'size' 'size' size new_flood = False new_flood False current_flood = s2.pop() current_flood s2.pop() s2.pop s2 pop current_flood['first_pos'] = j current_flood['first_pos'] current_flood 'first_pos' j current_flood['size'] += size current_flood['size'] current_flood 'size' size while True:
                    prev_flood = s2.pop()
                    if prev_flood is not None:
                        if prev_flood['first_pos'] > j:
                            current_flood['size'] += prev_flood['size']
                        else:
                            s2.push(prev_flood)
                            s2.push(current_flood)
                            break
                    else:
                        s2.push(current_flood)
                        break

    # print(s1.data)
    # print(s2.data)
    # print('----------') True prev_flood = s2.pop() prev_flood s2.pop() s2.pop s2 pop if prev_flood is not None:
                        if prev_flood['first_pos'] > j:
                            current_flood['size'] += prev_flood['size']
                        else:
                            s2.push(prev_flood)
                            s2.push(current_flood)
                            break
                    else:
                        s2.push(current_flood)
                        break

    # print(s1.data)
    # print(s2.data)
    # print('----------') prev_flood is not None prev_flood None if prev_flood['first_pos'] > j:
                            current_flood['size'] += prev_flood['size']
                        else:
                            s2.push(prev_flood)
                            s2.push(current_flood)
                            break
                     prev_flood['first_pos'] > j prev_flood['first_pos'] prev_flood 'first_pos' j current_flood['size'] += prev_flood['size'] current_flood['size'] current_flood 'size' prev_flood['size'] prev_flood 'size' s2.push(prev_flood) s2.push s2 push prev_flood s2.push(current_flood) s2.push s2 push current_flood break s2.push(current_flood) s2.push s2 push current_flood break print(A) print A output = str(s2.get_length()) output str(s2.get_length()) str s2.get_length() s2.get_length s2 get_length for elem in s2.data:
    output += ' ' + str(elem['size']) elem s2.data s2 data output += ' ' + str(elem['size']) output ' ' + str(elem['size']) ' ' str(elem['size']) str elem['size'] elem 'size' print(output) print output k = 0 0 k new_flood = True True new_flood new_flood = False False new_flood size = i - j i - j size class Stack:
    def __init__(self, data=None):
        # Pythonではクラスのデフォルト引数は１度しか初期化されないため、
        # うっかりdata=[]としてしまうと、複数のインスタンスを生成したときに
        # 同じ配列を参照することになってしまう！！！
        # http://amacbee.hatenablog.com/entry/2016/12/07/004510
        if data is None:
            self.data = []
        else:
            self.data = data

    def push(self, x):
        self.data.append(x)

    def pop(self):
        if self.is_empty() is True:
            return None
        else:
            return self.data.pop(-1)

    def is_empty(self):
        if len(self.data) == 0:
            return True
        else:
            return False

    def get_length(self):
        return len(self.data)

    def reverse(self):
        self.data.reverse()


# \\//
# \\///\_/\/\\\\/_/\\///__\\\_\\/_\/_/\ class Stack:
    def __init__(self, data=None):
        # Pythonではクラスのデフォルト引数は１度しか初期化されないため、
        # うっかりdata=[]としてしまうと、複数のインスタンスを生成したときに
        # 同じ配列を参照することになってしまう！！！
        # http://amacbee.hatenablog.com/entry/2016/12/07/004510
        if data is None:
            self.data = []
        else:
            self.data = data

    def push(self, x):
        self.data.append(x)

    def pop(self):
        if self.is_empty() is True:
            return None
        else:
            return self.data.pop(-1)

    def is_empty(self):
        if len(self.data) == 0:
            return True
        else:
            return False

    def get_length(self):
        return len(self.data)

    def reverse(self):
        self.data.reverse()


# \\//
# \\///\_/\/\\\\/_/\\///__\\\_\\/_\/_/\ Stack current_flood = s2.pop() s2.pop() current_flood A = 0 0 A diagram = input() input() diagram j = s1.pop() s1.pop() j new_flood = False False new_flood A += i - j i - j A prev_flood = s2.pop() s2.pop() prev_flood s2 = Stack() Stack() s2 s1 = Stack() Stack() s1 output += ' ' + str(elem['size']) ' ' + str(elem['size']) output output = str(s2.get_length()) str(s2.get_length()) output L = [] [] L

class Stack:
    def __init__(self, data=None):
        # Pythonではクラスのデフォルト引数は１度しか初期化されないため、
        # うっかりdata=[]としてしまうと、複数のインスタンスを生成したときに
        # 同じ配列を参照することになってしまう！！！
        # http://amacbee.hatenablog.com/entry/2016/12/07/004510
        if data is None:
            self.data = []
        else:
            self.data = data

    def push(self, x):
        self.data.append(x)

    def pop(self):
        if self.is_empty() is True:
            return None
        else:
            return self.data.pop(-1)

    def is_empty(self):
        if len(self.data) == 0:
            return True
        else:
            return False

    def get_length(self):
        return len(self.data)

    def reverse(self):
        self.data.reverse()


# \\//
# \\///\_/\/\\\\/_/\\///__\\\_\\/_\/_/\

diagram = input()
A = 0  # 総面積
k = 0  # 水たまりの数
L = []  # 各水たまりの面積

s1 = Stack()
s2 = Stack()

new_flood = False

# s1.push(10)
# s1.push(20)
# s1.push(30)
# print(s2.data)

for i, vector in enumerate(diagram):
    # print('----------')
    # print(i, vector)

    if vector == '\\':
        # print('下り')
        # print('test')
        s1.push(i)

        # 個別
        # data = {'first_pos': i, 'area': 0}
        # s2.push(data)
        # grad = 'down'

        new_flood = True

    elif vector == '/':
        # print('上り')
        j = s1.pop()
        if j is not None:
            # print(i, j)
            A += i - j

            # current_flood = s2.pop()
            # if current_flood['first_pos'] =
            # Agenshidan88
            # = i:
            #     current_flood['area'] += i - j

            size = i - j

            if new_flood is True:
                s2.push({'first_pos': j, 'size': size})
                new_flood = False

            # if s2.is_empty() is True:
            #     s2.push({'first_pos': j, 'area': i-j})

            else:
                current_flood = s2.pop()
                current_flood['first_pos'] = j
                current_flood['size'] += size

                while True:
                    prev_flood = s2.pop()
                    if prev_flood is not None:
                        if prev_flood['first_pos'] > j:
                            current_flood['size'] += prev_flood['size']
                        else:
                            s2.push(prev_flood)
                            s2.push(current_flood)
                            break
                    else:
                        s2.push(current_flood)
                        break

    # print(s1.data)
    # print(s2.data)
    # print('----------')

print(A)

output = str(s2.get_length())
for elem in s2.data:
    output += ' ' + str(elem['size'])

print(output)

