Colorful Chain

No attempts yetTime limit3sMemory limit512 MB

Problem

Bytie loves playing with colorful chains. He already owns quite a collection, and he likes some of them more than others. A chain is a row of colored links.

Byteasar has noticed that Bytie's taste is very precise. Bytie calls a contiguous fragment of a chain nice if it contains exactly l1l_1 links of color c1c_1, exactly l2l_2 links of color c2c_2, \dots, exactly lml_m links of color cmc_m, and no links of any other color. The appeal of a chain is the number of nice contiguous fragments it contains.

After many attempts Byteasar worked out the values c1,,cmc_1, \dots, c_m and l1,,lml_1, \dots, l_m. He now wants to buy a new chain, so he asks you for a program that helps him shop.

Input

The first line contains two integers nn and mm separated by a single space (1mn10000001 \le m \le n \le 1\,000\,000): the length of the chain and the length of the description of a nice fragment.

The second line contains mm integers l1,,lml_1, \dots, l_m separated by single spaces (1lin1 \le l_i \le n).

The third line contains mm integers c1,,cmc_1, \dots, c_m separated by single spaces (1cin1 \le c_i \le n, and cicjc_i \ne c_j whenever iji \ne j).

The sequences l1,,lml_1, \dots, l_m and c1,,cmc_1, \dots, c_m define a nice fragment: it has to contain exactly lil_i links of color cic_i.

The fourth line contains nn integers a1,,ana_1, \dots, a_n separated by single spaces (1ain1 \le a_i \le n), the colors of the successive links of the chain.

Output

Print a single integer, the number of nice contiguous fragments in the chain.

Hint

In the first example the nice fragments are 2 1 3 1 and 1 3 1 2, so the answer is 2.