#P8919. 『MdOI R5』Message

『MdOI R5』Message

Problem Description

Little A has a group chat. The group is playing a small game: given a function ff, starting from some time, when the xx-th message is sent, any member for whom f(x)=1f(x)=1 will receive a small punishment. The game ends when the total number of messages in the group reaches mm.

However, Little A is very talkative. During this period, he sent nn messages in the group. The ii-th message he sent is the aia_i-th message in the entire message history.

But Little A does not want to be punished, and he happens to be an administrator. He can recall any message sent by any group member at any time. Note that this will cause the rankings of all messages after that message to change.

But recalling too many messages may be seen as tyranny, so he wants to minimize the number of recalled messages, no matter whether they are his own or others'.

Now you can guess what you need to do: assuming other group members do nothing, given nn, the function ff, and aia_i, find the minimum number of messages he must recall.

Input Format

The first line contains two positive integers n,mn, m, representing the number of messages sent by Little A and the total number of messages in the group.

The second line is a 01 string of length mm, ff, where the ii-th character f(i)f(i) indicates whether the sender of the ii-th message will be punished.

The third line contains nn positive integers a1,a2,,ana_1, a_2, \ldots, a_n, representing the initial rankings of each of Little A's messages. It is guaranteed that the sequence aa is strictly increasing and 1aim1 \le a_i \le m.

Output Format

Output one line with an integer ansans, the minimum number of messages that must be recalled so that Little A will not be punished.

4 11
01101010001
2 6 8 11

2

Hint

[Sample Explanation]

One possible way is:

  • Little A first recalls the 11-st message (sent by another member). Now his four messages are the 1,5,7,101, 5, 7, 10-th messages in the message history.
  • Then he recalls the 55-th message (sent by himself). The remaining three messages are now the 1,6,91, 6, 9-th messages in the message history.

At this time, the three messages satisfy f(1)=f(6)=f(9)=0f(1)=f(6)=f(9)=0, which meets the requirement.

It can be proven that it is impossible to achieve the goal by recalling only one message.

[Constraints]

Subtask nn\le mm\le Special Property Score
1 1717 1717 1515
2 100100
3 10310^3 10410^4 2020
4 10510^5 n=mn=m 88
5 10510^5 10610^6 A 1212
6 3030
  • Special Property A: Little A never sends two messages in a row.

For all testdata, 1n1051 \le n \le 10^5, 1aim1061 \le a_i \le m \le 10^6, aia_i is strictly increasing, and f(i){0,1}f(i) \in \{0,1\}.

Translated by ChatGPT 5