#NOMURA2020E. Binary Programming

Binary Programming

Score : 900900 points

Problem Statement

Takahashi has an empty string SS and a variable xx whose initial value is 00.

Also, we have a string TT consisting of 0 and 1.

Now, Takahashi will do the operation with the following two steps T|T| times.

  • Insert a 0 or a 1 at any position of SS of his choice.
  • Then, increment xx by the sum of the digits in the odd positions (first, third, fifth, ...) of SS. For example, if SS is 01101, the digits in the odd positions are 0, 1, 1 from left to right, so xx is incremented by 22.

Print the maximum possible final value of xx in a sequence of operations such that SS equals TT in the end.

Constraints

  • 1T2×1051 \leq |T| \leq 2 \times 10^5
  • TT consists of 0 and 1.

Input

Input is given from Standard Input in the following format:

TT

Output

Print the maximum possible final value of xx in a sequence of operations such that SS equals TT in the end.

1101
5

Below is one sequence of operations that maximizes the final value of xx to 55.

  • Insert a 1 at the beginning of SS. SS becomes 1, and xx is incremented by 11.
  • Insert a 0 to the immediate right of the first character of SS. SS becomes 10, and xx is incremented by 11.
  • Insert a 1 to the immediate right of the second character of SS. SS becomes 101, and xx is incremented by 22.
  • Insert a 1 at the beginning of SS. SS becomes 1101, and xx is incremented by 11.
0111101101
26