#P979C. Kuro and Walking Route
Kuro and Walking Route
No submission language available for this problem.
Description
Kuro is living in a country called Uberland, consisting of towns, numbered from to , and bidirectional roads connecting these towns. It is possible to reach each town from any other. Each road connects two towns and . Kuro loves walking and he is planning to take a walking marathon, in which he will choose a pair of towns () and walk from using the shortest path to (note that is considered to be different from ).
Oddly, there are 2 special towns in Uberland named Flowrisa (denoted with the index ) and Beetopia (denoted with the index ). Flowrisa is a town where there are many strong-scent flowers, and Beetopia is another town where many bees live. In particular, Kuro will avoid any pair of towns if on the path from to , he reaches Beetopia after he reached Flowrisa, since the bees will be attracted with the flower smell on Kuro’s body and sting him.
Kuro wants to know how many pair of city he can take as his route. Since he’s not really bright, he asked you to help him with this problem.
The first line contains three integers , and (, , ) - the number of towns, index of the town Flowrisa and index of the town Beetopia, respectively.
lines follow, each line contains two integers and (, ), describes a road connecting two towns and .
It is guaranteed that from each town, we can reach every other town in the city using the given roads. That is, the given map of towns and roads is a tree.
A single integer resembles the number of pair of towns that Kuro can use as his walking route.
Input
The first line contains three integers , and (, , ) - the number of towns, index of the town Flowrisa and index of the town Beetopia, respectively.
lines follow, each line contains two integers and (, ), describes a road connecting two towns and .
It is guaranteed that from each town, we can reach every other town in the city using the given roads. That is, the given map of towns and roads is a tree.
Output
A single integer resembles the number of pair of towns that Kuro can use as his walking route.
Samples
Note
On the first example, Kuro can choose these pairs:
- : his route would be ,
- : his route would be ,
- : his route would be ,
- : his route would be ,
- : his route would be .
Kuro can't choose pair since his walking route would be , in which Kuro visits town (Flowrisa) and then visits town (Beetopia), which is not allowed (note that pair is still allowed because although Kuro visited Flowrisa and Beetopia, he did not visit them in that order).
On the second example, Kuro can choose the following pairs:
- : his route would be ,
- : his route would be ,
- : his route would be ,
- : his route would be .