import math
import sys
import itertools
from collections import deque
# import numpy as np

def main():
  S = sys.stdin.readline()
  len_S = len(S)

  index = 0 # 操作しているSのインデックス
  DOWN = [] # 下り文字をスタック
  POOL = [] # 水たまりごとの面積
  area = 0 # 総面積

  for s in S:
    if s == '\\':
      DOWN.append(index)

    elif s == '/' and len(DOWN) > 0:
      pool_start = DOWN.pop()
      pool_end = index
      tmp_area = pool_end - pool_start
      area += tmp_area

      while True:
        if len(POOL) == 0:
          break
        if POOL[-1]['start'] > pool_start and POOL[-1]['end'] < pool_end:
          tmp_area += POOL[-1]['area']
          POOL.pop()
        else:
          break

      POOL.append({'start': pool_start, 'end': pool_end, 'area': tmp_area})

    index += 1

  print(area)
  if len(POOL) > 0:
    print(len(POOL), end=" ")
    for i in range(len(POOL)-1):
      print(POOL[i]['area'], end=" ")
    print(POOL[-1]['area'])
  else:
    print(0)

if __name__ == '__main__':
  main() import math math import sys sys import itertools itertools from collections import deque def main():
  S = sys.stdin.readline()
  len_S = len(S)

  index = 0 # 操作しているSのインデックス
  DOWN = [] # 下り文字をスタック
  POOL = [] # 水たまりごとの面積
  area = 0 # 総面積

  for s in S:
    if s == '\\':
      DOWN.append(index)

    elif s == '/' and len(DOWN) > 0:
      pool_start = DOWN.pop()
      pool_end = index
      tmp_area = pool_end - pool_start
      area += tmp_area

      while True:
        if len(POOL) == 0:
          break
        if POOL[-1]['start'] > pool_start and POOL[-1]['end'] < pool_end:
          tmp_area += POOL[-1]['area']
          POOL.pop()
        else:
          break

      POOL.append({'start': pool_start, 'end': pool_end, 'area': tmp_area})

    index += 1

  print(area)
  if len(POOL) > 0:
    print(len(POOL), end=" ")
    for i in range(len(POOL)-1):
      print(POOL[i]['area'], end=" ")
    print(POOL[-1]['area'])
  else:
    print(0) main S = sys.stdin.readline() S sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline len_S = len(S) len_S len(S) len S index = 0 index 0 DOWN = [] DOWN [] POOL = [] POOL [] area = 0 area 0 for s in S:
    if s == '\\':
      DOWN.append(index)

    elif s == '/' and len(DOWN) > 0:
      pool_start = DOWN.pop()
      pool_end = index
      tmp_area = pool_end - pool_start
      area += tmp_area

      while True:
        if len(POOL) == 0:
          break
        if POOL[-1]['start'] > pool_start and POOL[-1]['end'] < pool_end:
          tmp_area += POOL[-1]['area']
          POOL.pop()
        else:
          break

      POOL.append({'start': pool_start, 'end': pool_end, 'area': tmp_area})

    index += 1

   s S if s == '\\':
      DOWN.append(index)

    elif s == '/' and len(DOWN) > 0:
      pool_start = DOWN.pop()
      pool_end = index
      tmp_area = pool_end - pool_start
      area += tmp_area

      while True:
        if len(POOL) == 0:
          break
        if POOL[-1]['start'] > pool_start and POOL[-1]['end'] < pool_end:
          tmp_area += POOL[-1]['area']
          POOL.pop()
        else:
          break

      POOL.append({'start': pool_start, 'end': pool_end, 'area': tmp_area})

     s == '\\' s '\\' DOWN.append(index) DOWN.append DOWN append index elif s == '/' and len(DOWN) > 0:
      pool_start = DOWN.pop()
      pool_end = index
      tmp_area = pool_end - pool_start
      area += tmp_area

      while True:
        if len(POOL) == 0:
          break
        if POOL[-1]['start'] > pool_start and POOL[-1]['end'] < pool_end:
          tmp_area += POOL[-1]['area']
          POOL.pop()
        else:
          break

      POOL.append({'start': pool_start, 'end': pool_end, 'area': tmp_area})

     s == '/' and len(DOWN) > 0 s == '/' s '/' len(DOWN) > 0 len(DOWN) len DOWN 0 pool_start = DOWN.pop() pool_start DOWN.pop() DOWN.pop DOWN pop pool_end = index pool_end index tmp_area = pool_end - pool_start tmp_area pool_end - pool_start pool_end pool_start area += tmp_area area tmp_area while True:
        if len(POOL) == 0:
          break
        if POOL[-1]['start'] > pool_start and POOL[-1]['end'] < pool_end:
          tmp_area += POOL[-1]['area']
          POOL.pop()
        else:
          break

       True if len(POOL) == 0:
          break
         len(POOL) == 0 len(POOL) len POOL 0 break if POOL[-1]['start'] > pool_start and POOL[-1]['end'] < pool_end:
          tmp_area += POOL[-1]['area']
          POOL.pop()
        else:
          break

       POOL[-1]['start'] > pool_start and POOL[-1]['end'] < pool_end POOL[-1]['start'] > pool_start POOL[-1]['start'] [-1] POOL -1 'start' pool_start POOL[-1]['end'] < pool_end POOL[-1]['end'] [-1] POOL -1 'end' pool_end tmp_area += POOL[-1]['area'] tmp_area POOL[-1]['area'] [-1] POOL -1 'area' POOL.pop() POOL.pop POOL pop break POOL.append({'start': pool_start, 'end': pool_end, 'area': tmp_area}) POOL.append POOL append {'start': pool_start, 'end': pool_end, 'area': tmp_area} 'start' 'start' pool_start 'end' 'end' pool_end 'area' 'area' tmp_area index += 1 index 1 print(area) print area if len(POOL) > 0:
    print(len(POOL), end=" ")
    for i in range(len(POOL)-1):
      print(POOL[i]['area'], end=" ")
    print(POOL[-1]['area'])
  else:
    print(0) len(POOL) > 0 len(POOL) len POOL 0 print(len(POOL), end=" ") print len(POOL) len POOL end=" " end " " for i in range(len(POOL)-1):
      print(POOL[i]['area'], end=" ")
     i range(len(POOL)-1) range len(POOL)-1 len(POOL) len POOL 1 print(POOL[i]['area'], end=" ") print POOL[i]['area'] [i] POOL i 'area' end=" " end " " print(POOL[-1]['area']) print POOL[-1]['area'] [-1] POOL -1 'area' print(0) print 0 if __name__ == '__main__':
  main() __name__ == '__main__' __name__ '__main__' main() main def main():
  S = sys.stdin.readline()
  len_S = len(S)

  index = 0 # 操作しているSのインデックス
  DOWN = [] # 下り文字をスタック
  POOL = [] # 水たまりごとの面積
  area = 0 # 総面積

  for s in S:
    if s == '\\':
      DOWN.append(index)

    elif s == '/' and len(DOWN) > 0:
      pool_start = DOWN.pop()
      pool_end = index
      tmp_area = pool_end - pool_start
      area += tmp_area

      while True:
        if len(POOL) == 0:
          break
        if POOL[-1]['start'] > pool_start and POOL[-1]['end'] < pool_end:
          tmp_area += POOL[-1]['area']
          POOL.pop()
        else:
          break

      POOL.append({'start': pool_start, 'end': pool_end, 'area': tmp_area})

    index += 1

  print(area)
  if len(POOL) > 0:
    print(len(POOL), end=" ")
    for i in range(len(POOL)-1):
      print(POOL[i]['area'], end=" ")
    print(POOL[-1]['area'])
  else:
    print(0) def main():
  S = sys.stdin.readline()
  len_S = len(S)

  index = 0 # 操作しているSのインデックス
  DOWN = [] # 下り文字をスタック
  POOL = [] # 水たまりごとの面積
  area = 0 # 総面積

  for s in S:
    if s == '\\':
      DOWN.append(index)

    elif s == '/' and len(DOWN) > 0:
      pool_start = DOWN.pop()
      pool_end = index
      tmp_area = pool_end - pool_start
      area += tmp_area

      while True:
        if len(POOL) == 0:
          break
        if POOL[-1]['start'] > pool_start and POOL[-1]['end'] < pool_end:
          tmp_area += POOL[-1]['area']
          POOL.pop()
        else:
          break

      POOL.append({'start': pool_start, 'end': pool_end, 'area': tmp_area})

    index += 1

  print(area)
  if len(POOL) > 0:
    print(len(POOL), end=" ")
    for i in range(len(POOL)-1):
      print(POOL[i]['area'], end=" ")
    print(POOL[-1]['area'])
  else:
    print(0) main
import math
import sys
import itertools
from collections import deque
# import numpy as np

def main():
  S = sys.stdin.readline()
  len_S = len(S)

  index = 0 # 操作しているSのインデックス
  DOWN = [] # 下り文字をスタック
  POOL = [] # 水たまりごとの面積
  area = 0 # 総面積

  for s in S:
    if s == '\\':
      DOWN.append(index)

    elif s == '/' and len(DOWN) > 0:
      pool_start = DOWN.pop()
      pool_end = index
      tmp_area = pool_end - pool_start
      area += tmp_area

      while True:
        if len(POOL) == 0:
          break
        if POOL[-1]['start'] > pool_start and POOL[-1]['end'] < pool_end:
          tmp_area += POOL[-1]['area']
          POOL.pop()
        else:
          break

      POOL.append({'start': pool_start, 'end': pool_end, 'area': tmp_area})

    index += 1

  print(area)
  if len(POOL) > 0:
    print(len(POOL), end=" ")
    for i in range(len(POOL)-1):
      print(POOL[i]['area'], end=" ")
    print(POOL[-1]['area'])
  else:
    print(0)

if __name__ == '__main__':
  main()
