Kevin Klein
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 clothing items, numbered from
to
.
Some pairs of clothing items match well together. Matching is mutual: if item matches item
, then item
also matches item
.
Kevin has selected 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 ,
, and
:
is the number of clothing items (
).
is the number of Kevin's favourite items (
).
is the number of matching pairs (
).
The next lines each contain one integer
(
), representing one of Kevin's favourite clothing items.
The next lines each contain two integers
and
, indicating that items
and
match each other (
).
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