B. Big Data
time limit per test
4 seconds
memory limit per test
1024 megabytes
input
standard input
output
standard output
Big data, machine learning, blockchain, artificial intelligence. Digital manufacturing, big data analysis, quantum communication, and internet of things.
Narendra Modi, 2019

You are given a sequence $$$a_1, a_2, \ldots, a_n$$$ of length $$$n$$$, consisting of ones and zeros.

Define the blockchain of a binary sequence as the list of lengths of blocks of equal elements in $$$a$$$. For example, $$$\text{blockchain}([1,0,0,1,1,1,0]) = [1,2,3,1]$$$, since the sequence consists of a single $$$1$$$, followed by two $$$0$$$s, followed by three $$$1$$$s, followed by a single $$$0$$$.

You are also given an integer sequence $$$b_1, b_2, \ldots, b_m$$$ of length $$$m$$$. Your goal is to make $$$\text{blockchain}(a)$$$ into a permutation of $$$b$$$, using the following operation:

  • Choose some $$$1 \le i \le n$$$, and flip the $$$i$$$-th element of $$$a$$$ (so if $$$a_i = 0$$$ it becomes $$$1$$$, and vice versa).

What's the minimum number of operations you need?

Input

The first line contains $$$n$$$ and $$$m$$$ ($$$1 \le m \le n \le 100$$$).

The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$0 \le a_i \le 1$$$).

The third line contains $$$m$$$ integers $$$b_1, b_2, \ldots, b_m$$$ ($$$1 \le b_i \le n$$$).

It is guaranteed that $$$b_1 + b_2 + \ldots + b_m = n$$$.

Output

Print the answer. We can show the goal is always achievable under the constraints of this problem.

Examples
Input
7 4
1 0 0 1 0 1 0
1 3 1 2
Output
1
Input
4 1
0 1 0 1
4
Output
2
Note

In the first test, initially, $$$\text{blockchain}(a) = [1,2,1,1,1,1]$$$. But if we flip the value at index $$$5$$$, we get $$$a = [1,0,0,1,1,1,0]$$$, and so $$$\text{blockchain}(a)=[1,2,3,1]$$$. Since $$$[1,2,3,1]$$$ is a permutation of $$$[1,3,1,2]$$$, we have achieved our goal.

In the second test, initially $$$\text{blockchain}([0,1,0,1]) = [1,1,1,1]$$$. We have two options, both of which take two operations  — we can either turn $$$a$$$ into $$$[0,0,0,0]$$$ or into $$$[1,1,1,1]$$$. Note that these two sequences are equivalent to the $$$\text{blockchain}$$$ function.