It is impossible to count how many times Yi'ai has been reborn. New flowers and the funeral bells of departure flow past her eyes like water. It is as if the memories in her mind are not of the past, but of an unchangeable future.
To call this endless cycle of torment "immortality" is a cruelty; it would be better to grant her death.
But this time, she feels a glimmer of "possibility"—the unknown. Crossing through despair...
What has not been restored in the countless restarts is not just Yi'ai's memory, but that rose from the "other shore," grown and nourished by hope, blood, and tears. This is the weapon that can challenge "Him."
The rose has grown $n$ flowers, connected in a tree structure. There are $m$ known paths. A path $(a, b)$ means that all the flowers on this path can be gathered together to generate a unit of power against the gods. However, once this power is generated, the flowers are consumed and cannot be used for other plans. In other words, one can select a set of vertex-disjoint paths from the tree, where each path generates one unit of power. Yi'ai has already calculated the maximum number of units of power that can be collected using these flowers, but... she is just a little short.
With just one more unit of power, she could challenge the gods.
Yi'ai draws her sword and cuts a wound on her arm. She wants to choose a path and stain the flowers on it with her blood, so that the ancient magic will take effect, and these flowers can also be used to generate a new unit of power.
Yi'ai wants to know how many different paths $(x, y)$ she can choose such that, when this path is considered alongside the original $m$ paths, the maximum number of vertex-disjoint paths that can be selected is greater than the number of paths that could be selected from the original $m$ paths.
Wage war on eternity, pursue me— Just like now, fingers tightly clasped. Shoot down the sun, offer it to me— Please remember, I am the god and the Buddha.
Input Format
The first line contains two integers $n$ and $m$, representing the number of rose flowers and the number of original power-generating schemes.
The next $n - 1$ lines each contain two positive integers $u$ and $v$, indicating that flowers $u$ and $v$ are directly connected.
The next $m$ lines each contain two positive integers $a$ and $b$, indicating that the flowers on the path from $a$ to $b$ can generate one unit of power.
Output Format
Output a single integer representing the number of feasible choices $(a, b)$ for Yi'ai.
Examples
Input 1
8 6 1 2 1 3 1 4 1 5 5 6 5 7 7 8 2 3 2 4 3 4 1 6 5 6 5 8
Output 1
8
Note
Originally, $2$ paths could be selected, for example: $(2, 3)$ and $(5, 8)$.
The following paths can be added:
- Add $(2, 2)$, then $3$ paths can be selected: $(2, 2), (3, 4), (5, 8)$.
- Add $(3, 3)$, then $3$ paths can be selected: $(3, 3), (2, 4), (5, 8)$.
- Add $(4, 4)$, then $3$ paths can be selected: $(4, 4), (2, 3), (5, 8)$.
- Add $(6, 6)$, then $3$ paths can be selected: $(6, 6), (2, 3), (5, 8)$.
- Add $(7, 7)$, then $3$ paths can be selected: $(7, 7), (2, 3), (5, 6)$.
- Add $(7, 8)$, then $3$ paths can be selected: $(7, 8), (2, 3), (5, 6)$.
- Add $(8, 7)$, then $3$ paths can be selected: $(8, 7), (2, 3), (5, 6)$.
- Add $(8, 8)$, then $3$ paths can be selected: $(8, 8), (2, 3), (5, 6)$.
Therefore, there are $8$ ways to add a path.
Constraints
For $100\%$ of the data, $2\le n \le 3 \times 10^5, 0\le m \le 3\times 10^5, 1\le u, v, a, b\le n$.
| Test Case | $n$ | $m$ | Data Type |
|---|---|---|---|
| $1,2$ | $=10$ | $\le10$ | C2 |
| $3,4$ | $=20$ | $\le20$ | |
| $5,6$ | $=30$ | $\le30$ | |
| $7,8$ | $=10^2$ | $\le10^2$ | |
| $9,10$ | $=300$ | $\le300$ | |
| $11$ | $=500$ | $\le500$ | |
| $12,13$ | $=10^3$ | $\le10^3$ | |
| $14,15$ | $=3,000$ | $\le3,000$ | |
| $16$ | $=99,991$ | $\le10^5$ | A1 |
| $17,18$ | $=99,992$ | A2 | |
| $19,20$ | $=99,993$ | B2 | |
| $21$ | $=99,994$ | C1 | |
| $22,23,24$ | $=10^5$ | C2 | |
| $25$ | $=3\times 10^5$ | $\le 3\times 10^5$ |
Definitions of data types:
A: Guaranteed $v = u + 1$.
B: Guaranteed $u = 1$.
C: No special constraints on the tree structure.
1: Guaranteed $a = b$.
2: No special constraints on the given paths.