#K74027. Counting Substrings That Start and End with 1

    ID: 34106 Type: Default 1000ms 256MiB

Counting Substrings That Start and End with 1

Counting Substrings That Start and End with 1

Given a binary string S, your task is to count the number of substrings that start and end with the character '1'. A substring is a contiguous sequence of characters within the string.

If there are n occurrences of '1' in the string, then the total number of valid substrings is computed by the formula:

\(\frac{n(n+1)}{2}\)

For example, if S = "10101", there are 3 occurrences of '1' and the answer is \(\frac{3 \times 4}{2} = 6\).

You need to read the input from standard input (stdin) and print the result to standard output (stdout).

inputFormat

The input consists of a single line containing a binary string S which comprises only the characters '0' and '1'.

outputFormat

Output a single integer representing the number of substrings that start and end with '1'.

## sample
10101
6