Postcards
InterviewTime limit1sMemory limit1024 MB
Count the friends reachable from Linas's close friends through known-each-other links, since every reached friend must also get a postcard.
Statement
Linas has friends, and of them are close friends. Some of Linas's friends also know each other.
Before Easter, Linas wants to draw one postcard for each of his close friends. However, Linas knows that if a friend receives a postcard, every other friend who knows that friend will envy them, unless they also receive a postcard.
"It is better to draw than to envy," Linas thinks. So he wants to draw as many postcards as needed so that:
- every close friend of Linas receives a postcard,
- no friend envies another friend.
For example, suppose Linas has three friends, Domas, Tomas and Vytautas, but only Domas is a close friend. If Tomas and Domas know each other, Linas also draws a postcard for Tomas. If Tomas and Vytautas know each other too, Linas also draws a postcard for Vytautas, so that he does not envy Tomas.
You are given Linas's friends, his close friends, and which friends know each other. Find how many postcards Linas must draw so that all his close friends receive one and no friend envies another.
Input
The first line contains three integers , and : the number of friends, the number of close friends, and the number of pairs of friends who know each other. The friends are numbered from to .
The next lines contain the numbers () of the close friends.
Each of the next lines contains a pair meaning that friends and know each other, where .
Output
Print one integer: the total number of postcards Linas must draw so that all of his close friends receive one and no friend envies another.
Constraints