
from collections import deque

def main():
    s1 = deque()
    s2 = deque()
    total = 0

    string = input()

    for i in range(len(string)):
        if string[i] == '\\':
            s1.append(i)
        elif string[i] == '/' and len(s1) > 0:
            j = s1.pop()
            a = i - j
            total += a

            while (len(s2) > 0 and s2[-1][0] > j):
                a += s2[-1][1]
                s2.pop()

            s2.append((j, a))

    ans = []
    while (len(s2) > 0):
        ans.append(s2[-1][1])
        s2.pop()

    print(total)

    print(len(ans), *ans[::-1])

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

    string = input()

    for i in range(len(string)):
        if string[i] == '\\':
            s1.append(i)
        elif string[i] == '/' and len(s1) > 0:
            j = s1.pop()
            a = i - j
            total += a

            while (len(s2) > 0 and s2[-1][0] > j):
                a += s2[-1][1]
                s2.pop()

            s2.append((j, a))

    ans = []
    while (len(s2) > 0):
        ans.append(s2[-1][1])
        s2.pop()

    print(total)

    print(len(ans), *ans[::-1]) main s1 = deque() s1 deque() deque s2 = deque() s2 deque() deque total = 0 total 0 string = input() string input() input for i in range(len(string)):
        if string[i] == '\\':
            s1.append(i)
        elif string[i] == '/' and len(s1) > 0:
            j = s1.pop()
            a = i - j
            total += a

            while (len(s2) > 0 and s2[-1][0] > j):
                a += s2[-1][1]
                s2.pop()

            s2.append((j, a))

     i range(len(string)) range len(string) len string if string[i] == '\\':
            s1.append(i)
        elif string[i] == '/' and len(s1) > 0:
            j = s1.pop()
            a = i - j
            total += a

            while (len(s2) > 0 and s2[-1][0] > j):
                a += s2[-1][1]
                s2.pop()

            s2.append((j, a))

     string[i] == '\\' string[i] string i '\\' s1.append(i) s1.append s1 append i elif string[i] == '/' and len(s1) > 0:
            j = s1.pop()
            a = i - j
            total += a

            while (len(s2) > 0 and s2[-1][0] > j):
                a += s2[-1][1]
                s2.pop()

            s2.append((j, a))

     string[i] == '/' and len(s1) > 0 string[i] == '/' string[i] string i '/' len(s1) > 0 len(s1) len s1 0 j = s1.pop() j s1.pop() s1.pop s1 pop a = i - j a i - j i j total += a total a while (len(s2) > 0 and s2[-1][0] > j):
                a += s2[-1][1]
                s2.pop()

             len(s2) > 0 and s2[-1][0] > j len(s2) > 0 len(s2) len s2 0 s2[-1][0] > j s2[-1][0] [-1] s2 -1 0 j a += s2[-1][1] a s2[-1][1] [-1] s2 -1 1 s2.pop() s2.pop s2 pop s2.append((j, a)) s2.append s2 append (j, a) j a ans = [] ans [] while (len(s2) > 0):
        ans.append(s2[-1][1])
        s2.pop()

     len(s2) > 0 len(s2) len s2 0 ans.append(s2[-1][1]) ans.append ans append s2[-1][1] [-1] s2 -1 1 s2.pop() s2.pop s2 pop print(total) print total print(len(ans), *ans[::-1]) print len(ans) len ans *ans[::-1] ans[::-1] ans ::-1 -1 if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    s1 = deque()
    s2 = deque()
    total = 0

    string = input()

    for i in range(len(string)):
        if string[i] == '\\':
            s1.append(i)
        elif string[i] == '/' and len(s1) > 0:
            j = s1.pop()
            a = i - j
            total += a

            while (len(s2) > 0 and s2[-1][0] > j):
                a += s2[-1][1]
                s2.pop()

            s2.append((j, a))

    ans = []
    while (len(s2) > 0):
        ans.append(s2[-1][1])
        s2.pop()

    print(total)

    print(len(ans), *ans[::-1]) def main():
    s1 = deque()
    s2 = deque()
    total = 0

    string = input()

    for i in range(len(string)):
        if string[i] == '\\':
            s1.append(i)
        elif string[i] == '/' and len(s1) > 0:
            j = s1.pop()
            a = i - j
            total += a

            while (len(s2) > 0 and s2[-1][0] > j):
                a += s2[-1][1]
                s2.pop()

            s2.append((j, a))

    ans = []
    while (len(s2) > 0):
        ans.append(s2[-1][1])
        s2.pop()

    print(total)

    print(len(ans), *ans[::-1]) main

from collections import deque

def main():
    s1 = deque()
    s2 = deque()
    total = 0

    string = input()

    for i in range(len(string)):
        if string[i] == '\\':
            s1.append(i)
        elif string[i] == '/' and len(s1) > 0:
            j = s1.pop()
            a = i - j
            total += a

            while (len(s2) > 0 and s2[-1][0] > j):
                a += s2[-1][1]
                s2.pop()

            s2.append((j, a))

    ans = []
    while (len(s2) > 0):
        ans.append(s2[-1][1])
        s2.pop()

    print(total)

    print(len(ans), *ans[::-1])

if __name__ == "__main__":
    main()