output_description: Print the maximum possible final value of x in a sequence of operations such
  that S equals T in the end.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      T
attempt: # import itertools
  # import numpy as np
  # from scipy.sparse.csgraph import minimum_spanning_tree
  # from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
  
  from itertools import accumulate
  
  
  def main():
      T = [int(c) for c in input()]
      odd = [T[i] for i in range(len(T)) if i % 2 == 0]
      even = [T[i] for i in range(len(T)) if i % 2 != 0]
  
      ret = 0
      acc_odd = list(accumulate(odd))
      acc_even = list(accumulate(even))
      while len(acc_even) > 0:
          score = 0
          # print(f'odd:{odd}')
          # print(f'even:{even}')
          # print(f'acc_odd:{acc_odd}')
          # print(f'acc_even:{acc_even}')
          pos = (-1, False)
          for i in range(len(odd)):
              if i == 0:
                  x = acc_even[-1]
                  y = acc_odd[i] + acc_even[-1] - acc_even[i]
              elif i == len(odd) - 1:
                  x = acc_odd[i - 1] + acc_even[-1] - acc_even[i - 1]
                  if len(acc_even) == len(acc_odd):
                      y = acc_odd[i] + acc_even[-1] - acc_even[i]
                      assert y == acc_odd[i]
                  else:
                      y = 0
              else:
                  x = acc_odd[i - 1] + acc_even[-1] - acc_even[i - 1]
                  y = acc_odd[i] + acc_even[-1] - acc_even[i]
              if x > y and x > score:
                  pos = (i, True)
                  score = x
              elif y > x and y > score:
                  pos = (i, False)
                  score = y
              elif x == y and x > score:  # ???
                  # print(f'x==y=={x}!!!')
                  if odd[i] == 0:
                      pos = (i, True)
                      score = x
                  else:
                      pos = (i, False)
                      score = y
          ret += score
          # print(f'pos:{pos}')
          # print(f'score:{score}')
          assert pos[0] != -1
          if pos[1]:  # oddから抜く
              odd_ = odd[: pos[0]]
              odd_.extend(even[pos[0] :])
              even_ = even[: pos[0]]
              even_.extend(odd[pos[0] + 1 :])
          else:  # evenから抜く
              odd_ = odd[: pos[0] + 1]
              odd_.extend(even[pos[0] + 1 :])  # 超えた場合は空リストになるっぽい
              even_ = even[: pos[0]]
              even_.extend(odd[pos[0] + 1 :])
          odd, even = odd_.copy(), even_.copy()
          acc_odd = list(accumulate(odd))
          acc_even = list(accumulate(even))
      if len(odd) == 1:
          ret += odd[0]
      print(ret)
  
  
  if __name__ == "__main__":
      main()
  
problem_description: Statement
  
  Takahashi has an empty string S and a variable x whose initial value is 0.
  
  Also, we have a string T consisting of `0` and `1`.
  
  Now, Takahashi will do the operation with the following two steps |T| times.
  
    * Insert a `0` or a `1` at any position of S of his choice.
    * Then, increment x by the sum of the digits in the odd positions (first, third, fifth, ...) of S. For example, if S is `01101`, the digits in the odd positions are `0`, `1`, `1` from left to right, so x is incremented by 2.
  
  Print the maximum possible final value of x in a sequence of operations such
  that S equals T in the end.
samples: [{"input": "1101", "output": "5\n    \n\nBelow is one sequence of operations that maximizes the final value of x to 5.\n\n  * Insert a `1` at the beginning of S. S becomes `1`, and x is incremented by 1.\n  * Insert a `0` to the immediate right of the first character of S. S becomes `10`, and x is incremented by 1.\n  * Insert a `1` to the immediate right of the second character of S. S becomes `101`, and x is incremented by 2.\n  * Insert a `1` at the beginning of S. S becomes `1101`, and x is incremented by 1.\n\n* * *"}, {"input": "0111101101", "output": "26"}]