Returning Lights To Box

아직 제출이 없습니다시간 제한1초메모리 제한512 MB

문제

Wesley needs to take down his holiday lights. He has a line of NN lights, some of which may be on, and Wesley needs all the lights to be off before he can unplug them (or else he will receive a deadly electrical shock). 

Each light has a corresponding switch that can be used to turn the light on or off, and Wesley can use at most one of these switches every second, starting from the first second. However, these lights are finicky, and in the next MM seconds they will toggle their state on their own! Specifically, at the end of ii-th second, the b_ib\_i-th light will flip its state: turn on if it was off, or turn off if it was on. Wesley wants to take the lights down as soon as possible, so he would like to know what is the earliest time possible for all the lights to be off, assuming he uses switches in an ideal manner. In particular, output the least ii such that all lights can be turned off by the end of the ii-th second by some sequence of switch usages. Note that if all lights are initially off, then the least such ii is 0.

입력

The first line contains two integers NN and MM, the number of lights and the number of unsolicited changes the lights will make (1N,M21051 \le N, M \le 2 \cdot 10^5).

The second line will contain NN integers a_1,a_2,,a_Na\_1, a\_2, \ldots, a\_N (0a_i10 \le a\_i \le 1), the initial state of the lights. Here, a_i=1a\_i = 1 indicates that the ii-th light is initially on, and a_i=0a\_i = 0 tells it is off.

The third and final line will contain MM integers b_1,b_2,b_Mb\_1, b\_2, \ldots b\_M, which denotes that the b_ib\_i-th light flips its state at the end of ii-th second (1b_iN1 \le b\_i \le N).

출력

Output a single integer, the earliest time (in seconds) it will take for Wesley to turn all the lights off. Note that if all the lights can be turned off before MM seconds have passed, Wesley will ignore any future toggles and take them down immediately.