## DMOPC '21 Contest 6 P2 - Gacha Luck

View as PDF

Points: 7 (partial)
Time limit: 3.0s
Memory limit: 1G

Author:
Problem type

Your friend has just accused you of having good gacha luck. To prove them wrong, you have been keeping track of the results of every gacha pull over the past few months in a spreadsheet. Specifically, your spreadsheet contains entries, each containing a value of either a or a . A value of in the -th entry denotes that the -th pull contained a 4 star card, and a denotes otherwise. The unluckiness score of a subsection (a contiguous subsequence) of these entries is calculated as follows:

1. The score is initially set to be the number of s in the subsection.
2. Then, for each in the subsection, the unluckiness score is halved without rounding.
3. Finally, the score is set to be the smallest integer that is no smaller than its current value.

To refute their claim as effectively as possible, you will send them screenshots containing mutually disjoint subsections of your spreadsheet. What is the maximum possible total unluckiness score of the subsections in the screenshots?

#### Input Specification

The first line contains integers and .

The second line contains a binary string of length , representing the entries of the spreadsheet in order.

#### Output Specification

Output a single integer on its own line, the maximum possible total unluckiness score of the subsections.

#### Sample Input

9 2
001000100

#### Sample Output

5

#### Explanation

One optimal solution would be to include the first entries in the first screenshot and the -th and -th entries in the second. These have unluckiness scores of and respectively, giving a total unluckiness score of .