Traitor

No attempts yetTime limit1sMemory limit128 MB

Problem

An intelligence source tells us there is a traitor inside the ACM Security Agency (ASA). ASA has a hierarchical structure: every agent has one manager, and at least one top manager is not managed by anyone. Our source does not know exactly who the traitor is, but he has a list of suspects. So all we know is that the agency has exactly one traitor and that we have this list of suspects. To find the traitor we want to assign one watcher to each suspect, and the assignment has to satisfy three conditions.

  1. Two suspects cannot watch each other. An assignment in which agent xx watches agent yy while yy watches xx is forbidden.
  2. Each suspect must be watched by his manager or by one of his direct employees.
  3. Nobody can watch more than one suspect.

Under all three conditions it may be impossible to watch every suspect. Write a program that reads the structure of ASA and the list of suspects, then reports the maximum number of suspects for whom the watcher assignment is possible.

The figure below shows the organizational structure of ASA with two top managers and eleven agents, and the suspects are gray. Here an assignment covering 7 of the 8 suspects is possible, drawn with arrows. An arrow from agent xx to agent yy means xx watches yy. It can be shown that this example has no assignment covering all suspects.

ASA structure with one watcher assignment

Input

The input contains multiple test cases. The first line of each test case has two integers, the number of agents nn (1n100001 \le n \le 10\,000) and the number of suspected agents kk (1kn1 \le k \le n). The agents are numbered from 1 to nn. The second line has nn space separated integers, where the iith number is the number of the agent who manages agent ii, and a zero means agent ii is a top manager. The third line has the numbers of the suspected agents, s1,s2,,sks_1, s_2, \ldots, s_k. The input ends with a line containing 0 0, which should not be processed.

Output

For each test case, print on one line the maximum number of suspects for whom the watcher assignment is possible.