Xiaochang and Xiaopeng are preparing for the postgraduate entrance exam together, sitting back-to-back in the study room day after day.
Originally, Xiaochang was better at studying than Xiaopeng, so he doesn't want Xiaopeng to surpass him. Xiaopeng is very hardworking himself, but he doesn't want Xiaochang to see him working too hard.
Specifically:
Over the next $$$n \times m$$$ days, at 11:00 am on the $$$k$$$-th day ($$$0 \le k \lt n \times m$$$):
The trust level of Xiaochang towards Xiaopeng increases by 1 in the following two cases:
Given $$$n$$$, $$$m$$$, and Xiaochang's sequences, the question is: Assuming Xiaopeng constructs his sequence in the optimal way, what is the maximum trust level Xiaochang can have towards Xiaopeng after $$$n \times m$$$ days?
The first line contains two positive integers $$$n$$$ and $$$m$$$, as described in the problem statement.
The second line contains a binary string of length $$$n$$$, representing Xiaochang's sequence $$$A$$$.
$$$1 \le n,m \le 10^5$$$
Output a single number representing the answer.
3 4111
12
3 2101
4
For the first sample case, Xiaopeng can set his sequence to 0000, so whenever Xiaochang looks back, Xiaopeng is playing, resulting in the answer $$$n \times m=3 \times 4=12$$$.
For the second sample case, during these 6 days, Xiaopeng's observation sequence is 101101, while Xiaochang's sequence expands to $$$B_0B_1B_0B_1B_0B_1$$$.
Each day's decisions correspond to: $$$\{1,B_0\}$$$, $$$\{0,B_1\}$$$, $$$\{1,B_0\}$$$, $$$\{1,B_1\}$$$, $$$\{0,B_0\}$$$, $$$\{1,B_1\}$$$.
It's easy to see that setting $$$B_0=B_1=0$$$ yields the maximum answer of 4.
| Название |
|---|


