Kevin Klein


Submit solution

Points: 1
Time limit: 2.0s
Memory limit: 256M

Author:
Problem type
Allowed languages
C, C++, Java, Python, Rust

After decades of thriving in software engineering, Kevin decides to make a bold move into the fashion industry. He launches a famous clothing brand called Kevin Klein and is now preparing for an upcoming Fashion Week.

Kevin owns n clothing items, numbered from 1 to n.

Some pairs of clothing items match well together. Matching is mutual: if item u matches item v, then item v also matches item u.

Kevin has selected k of his favourite clothing items. Starting with these items, he wants to build the largest possible collection for his Fashion Week showcase.

A clothing item can be added to the collection if:

  • it is one of Kevin's favourite items, or
  • it matches with an item already in the collection.

Determine how many clothing items Kevin can include in his final collection.

Input

The first line contains three integers n, k, and m:

  • n is the number of clothing items (1 \leq n \leq 10^5).
  • k is the number of Kevin's favourite items (0 \leq k \leq n).
  • m is the number of matching pairs (0 \leq m \leq 2\times 10^5).

The next k lines each contain one integer x (1 \leq x \leq n), representing one of Kevin's favourite clothing items.

The next m lines each contain two integers u and v, indicating that items u and v match each other (1 \leq u, v \leq n, u < v).

Also:

  • All favourite items are distinct.
  • All matching pairs are distinct.

Output

Print one integer: the number of clothing items Kevin can include in his collection.

Example

Input 1
6 1 3
1
1 2
2 3
4 5
Output 1
3

Item 1 is a favourite item. From item 1, Kevin can add item 2, then item 3. Items 4 and 5 are not connected to any favourite item, so the final collection contains 3 items.

Input 2
5 2 4
1
5
1 2
2 3
3 4
4 5
Output 2
5

Items 1 and 5 are favourite items. Since all items are connected through matching pairs, Kevin can include all 5 items.

Input 3
4 0 2
1 2
3 4
Output 3
0

Kevin has no favourite items, so there are no initial items in the collection. Therefore, no other items can be added.


Comments

There are no comments at the moment.