from collections import deque

if __name__ == '__main__':
    s = input()
    s1 = deque()
    s2 = deque()
    summ = 0
    for i, c in enumerate(s):
        if c == '\\':
            s1.append(i)
        elif s[i] == '/' and len(s1) > 0:
            j = s1.pop()
            summ += i-j
            a = i-j
            while len(s2) > 0 and s2[-1][0] > j:
                a+= s2.pop()[1]
            s2.append([j, a])
    
    ans = []
    while len(s2) > 0:
        ans.append(s2.pop()[1])
    ans.reverse()
    print(sum(ans))
    counter = len(ans)
    ans.insert(0, counter)
    a = list(map(str, ans))
    print(' '.join(a)) from collections import deque if __name__ == '__main__':
    s = input()
    s1 = deque()
    s2 = deque()
    summ = 0
    for i, c in enumerate(s):
        if c == '\\':
            s1.append(i)
        elif s[i] == '/' and len(s1) > 0:
            j = s1.pop()
            summ += i-j
            a = i-j
            while len(s2) > 0 and s2[-1][0] > j:
                a+= s2.pop()[1]
            s2.append([j, a])
    
    ans = []
    while len(s2) > 0:
        ans.append(s2.pop()[1])
    ans.reverse()
    print(sum(ans))
    counter = len(ans)
    ans.insert(0, counter)
    a = list(map(str, ans))
    print(' '.join(a)) __name__ == '__main__' __name__ '__main__' s = input() s input() input s1 = deque() s1 deque() deque s2 = deque() s2 deque() deque summ = 0 summ 0 for i, c in enumerate(s):
        if c == '\\':
            s1.append(i)
        elif s[i] == '/' and len(s1) > 0:
            j = s1.pop()
            summ += i-j
            a = i-j
            while len(s2) > 0 and s2[-1][0] > j:
                a+= s2.pop()[1]
            s2.append([j, a])
    
     i c enumerate(s) enumerate s if c == '\\':
            s1.append(i)
        elif s[i] == '/' and len(s1) > 0:
            j = s1.pop()
            summ += i-j
            a = i-j
            while len(s2) > 0 and s2[-1][0] > j:
                a+= s2.pop()[1]
            s2.append([j, a])
    
     c == '\\' c '\\' s1.append(i) s1.append s1 append i elif s[i] == '/' and len(s1) > 0:
            j = s1.pop()
            summ += i-j
            a = i-j
            while len(s2) > 0 and s2[-1][0] > j:
                a+= s2.pop()[1]
            s2.append([j, a])
    
     s[i] == '/' and len(s1) > 0 s[i] == '/' s[i] s i '/' len(s1) > 0 len(s1) len s1 0 j = s1.pop() j s1.pop() s1.pop s1 pop summ += i-j summ i-j i j a = i-j a i-j i j while len(s2) > 0 and s2[-1][0] > j:
                a+= s2.pop()[1]
             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.pop()[1] a s2.pop()[1] s2.pop() s2.pop s2 pop 1 s2.append([j, a]) s2.append s2 append [j, a] j a ans = [] ans [] while len(s2) > 0:
        ans.append(s2.pop()[1])
     len(s2) > 0 len(s2) len s2 0 ans.append(s2.pop()[1]) ans.append ans append s2.pop()[1] s2.pop() s2.pop s2 pop 1 ans.reverse() ans.reverse ans reverse print(sum(ans)) print sum(ans) sum ans counter = len(ans) counter len(ans) len ans ans.insert(0, counter) ans.insert ans insert 0 counter a = list(map(str, ans)) a list(map(str, ans)) list map(str, ans) map str ans print(' '.join(a)) print ' '.join(a) ' '.join ' ' join a s1 = deque() deque() s1 summ += i-j i-j summ a+= s2.pop()[1] s2.pop()[1] a s = input() input() s s2 = deque() deque() s2 j = s1.pop() s1.pop() j counter = len(ans) len(ans) counter a = i-j i-j a a = list(map(str, ans)) list(map(str, ans)) a ans = [] [] ans summ = 0 0 summ
from collections import deque

if __name__ == '__main__':
    s = input()
    s1 = deque()
    s2 = deque()
    summ = 0
    for i, c in enumerate(s):
        if c == '\\':
            s1.append(i)
        elif s[i] == '/' and len(s1) > 0:
            j = s1.pop()
            summ += i-j
            a = i-j
            while len(s2) > 0 and s2[-1][0] > j:
                a+= s2.pop()[1]
            s2.append([j, a])
    
    ans = []
    while len(s2) > 0:
        ans.append(s2.pop()[1])
    ans.reverse()
    print(sum(ans))
    counter = len(ans)
    ans.insert(0, counter)
    a = list(map(str, ans))
    print(' '.join(a))
