import sys
from collections import deque
def input():
    return sys.stdin.readline()[:-1]
A = input()

total = 0
total_each = deque()
S1 = deque()
S2 = deque()
for j,a in enumerate(A):
    #print('j = {}, S2 = {}'.format(j,S2))
    if a == '\\':
        S1.append(j)
    elif a=='/':
        try:
            i = S1.pop()
            val_new = j-i
            total += val_new
            
            if len(S2)==0:
                S2.append((i,val_new))
                continue
            
            while True:
                if len(S2)>0:
                    a,val = S2[-1]
                    if a<i:
                        S2.append((i, val_new))
                        break
                    elif i<a:
                        _ = S2.pop()
                        val_new = val + val_new
                else:
                    S2.append((i,val_new))
                    break
        except:
            pass
print(total)
ans = [len(S2)]
for _ in range(len(S2)):
    a,val = S2.popleft()
    ans.append(val)
print(*ans) import sys sys from collections import deque def input():
    return sys.stdin.readline()[:-1] input return sys.stdin.readline()[:-1] sys.stdin.readline()[:-1] sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline :-1 -1 A = input() A input() input total = 0 total 0 total_each = deque() total_each deque() deque S1 = deque() S1 deque() deque S2 = deque() S2 deque() deque for j,a in enumerate(A):
    #print('j = {}, S2 = {}'.format(j,S2))
    if a == '\\':
        S1.append(j)
    elif a=='/':
        try:
            i = S1.pop()
            val_new = j-i
            total += val_new
            
            if len(S2)==0:
                S2.append((i,val_new))
                continue
            
            while True:
                if len(S2)>0:
                    a,val = S2[-1]
                    if a<i:
                        S2.append((i, val_new))
                        break
                    elif i<a:
                        _ = S2.pop()
                        val_new = val + val_new
                else:
                    S2.append((i,val_new))
                    break
        except:
            pass j a enumerate(A) enumerate A if a == '\\':
        S1.append(j)
    elif a=='/':
        try:
            i = S1.pop()
            val_new = j-i
            total += val_new
            
            if len(S2)==0:
                S2.append((i,val_new))
                continue
            
            while True:
                if len(S2)>0:
                    a,val = S2[-1]
                    if a<i:
                        S2.append((i, val_new))
                        break
                    elif i<a:
                        _ = S2.pop()
                        val_new = val + val_new
                else:
                    S2.append((i,val_new))
                    break
        except:
            pass a == '\\' a '\\' S1.append(j) S1.append S1 append j elif a=='/':
        try:
            i = S1.pop()
            val_new = j-i
            total += val_new
            
            if len(S2)==0:
                S2.append((i,val_new))
                continue
            
            while True:
                if len(S2)>0:
                    a,val = S2[-1]
                    if a<i:
                        S2.append((i, val_new))
                        break
                    elif i<a:
                        _ = S2.pop()
                        val_new = val + val_new
                else:
                    S2.append((i,val_new))
                    break
        except:
            pass a=='/' a '/' try:
            i = S1.pop()
            val_new = j-i
            total += val_new
            
            if len(S2)==0:
                S2.append((i,val_new))
                continue
            
            while True:
                if len(S2)>0:
                    a,val = S2[-1]
                    if a<i:
                        S2.append((i, val_new))
                        break
                    elif i<a:
                        _ = S2.pop()
                        val_new = val + val_new
                else:
                    S2.append((i,val_new))
                    break
        except:
            pass except:
            pass i = S1.pop() i S1.pop() S1.pop S1 pop val_new = j-i val_new j-i j i total += val_new total val_new if len(S2)==0:
                S2.append((i,val_new))
                continue
            
             len(S2)==0 len(S2) len S2 0 S2.append((i,val_new)) S2.append S2 append (i,val_new) i val_new continue while True:
                if len(S2)>0:
                    a,val = S2[-1]
                    if a<i:
                        S2.append((i, val_new))
                        break
                    elif i<a:
                        _ = S2.pop()
                        val_new = val + val_new
                else:
                    S2.append((i,val_new))
                    break
         True if len(S2)>0:
                    a,val = S2[-1]
                    if a<i:
                        S2.append((i, val_new))
                        break
                    elif i<a:
                        _ = S2.pop()
                        val_new = val + val_new
                else:
                    S2.append((i,val_new))
                    break
         len(S2)>0 len(S2) len S2 0 a,val = S2[-1] a S2[-1] S2 -1 val if a<i:
                        S2.append((i, val_new))
                        break
                    elif i<a:
                        _ = S2.pop()
                        val_new = val + val_new
                 a<i a i S2.append((i, val_new)) S2.append S2 append (i, val_new) i val_new break elif i<a:
                        _ = S2.pop()
                        val_new = val + val_new
                 i<a i a _ = S2.pop() _ S2.pop() S2.pop S2 pop val_new = val + val_new val_new val + val_new val val_new S2.append((i,val_new)) S2.append S2 append (i,val_new) i val_new break print(total) print total ans = [len(S2)] ans [len(S2)] len(S2) len S2 for _ in range(len(S2)):
    a,val = S2.popleft()
    ans.append(val) _ range(len(S2)) range len(S2) len S2 a,val = S2.popleft() a S2.popleft() S2.popleft S2 popleft val ans.append(val) ans.append ans append val print(*ans) print *ans ans a,val = S2[-1] S2[-1] a val = S2.popleft() S2.popleft() val _ = S2.pop() S2.pop() _ val_new = val + val_new val + val_new val_new total = 0 0 total ans = [len(S2)] [len(S2)] ans i = S1.pop() S1.pop() i S1 = deque() deque() S1 S2 = deque() deque() S2 A = input() input() A total_each = deque() deque() total_each a,val = S2.popleft() S2.popleft() a val = S2[-1] S2[-1] val val_new = j-i j-i val_new def input():
    return sys.stdin.readline()[:-1] def input():
    return sys.stdin.readline()[:-1] input total += val_new val_new total
import sys
from collections import deque
def input():
    return sys.stdin.readline()[:-1]
A = input()

total = 0
total_each = deque()
S1 = deque()
S2 = deque()
for j,a in enumerate(A):
    #print('j = {}, S2 = {}'.format(j,S2))
    if a == '\\':
        S1.append(j)
    elif a=='/':
        try:
            i = S1.pop()
            val_new = j-i
            total += val_new
            
            if len(S2)==0:
                S2.append((i,val_new))
                continue
            
            while True:
                if len(S2)>0:
                    a,val = S2[-1]
                    if a<i:
                        S2.append((i, val_new))
                        break
                    elif i<a:
                        _ = S2.pop()
                        val_new = val + val_new
                else:
                    S2.append((i,val_new))
                    break
        except:
            pass
print(total)
ans = [len(S2)]
for _ in range(len(S2)):
    a,val = S2.popleft()
    ans.append(val)
print(*ans)
