Given a tree of nodes, and two paths, one from to and another from to , find the number of nodes that are part of both paths.
Input Specification
The first line will contain the integer .
The second line will contain four integers, .
The next lines will each contain two integers, .
It is guaranteed the entire tree is connected.
Output Specification
Output the number of nodes that are part of both paths.
Sample Input
5
1 5 2 4
1 3
2 4
3 4
5 4
Sample Output
1
Explanation for Sample
Only node is part of both paths.
Comments