Cow Meows has a tree of size $$$n$$$ rooted at node $$$1$$$ and a constant integer $$$k$$$.
However, he is over $$$10^{10^{100}}$$$ years old, and math formulas have started messing with his vision.
Specifically, he thinks that two nodes $$$a$$$ and $$$b$$$ are similar if there exists any node $$$u$$$ that is an ancestor of both $$$a$$$ and $$$b$$$, and $$$dist(a, u) \equiv dist(b, u) \equiv 0 \pmod{k}$$$, where $$$dist(u, v)$$$ represents the number of edges in the simple path from $$$u$$$ to $$$v$$$.
Your goal is to help Cow Meows count the number of pairs $$$(u, v)$$$, $$$1\leq u \lt v \leq n$$$, such that nodes $$$u$$$ and $$$v$$$ are similar.
The first line contains two integers $$$n$$$ and $$$k$$$, $$$(1 \le k \le n \le 2 \cdot 10^5)$$$, the size of the tree and the constant respectively.
The second line contains $$$n-1$$$ integers $$$p_2, p_3, ..., p_n$$$, where $$$p_i$$$ is the parent of the $$$i$$$-$$$th$$$ vertex.
It is guaranteed that the input forms a valid tree.
Output exactly one integer, the number of distinct unordered pairs of similar nodes.
5 21 2 2 4
4
5 51 2 3 4
0
4 41 1 1
0
4 11 1 1
6
In the first example, the tree is the following:
With $$$k = 2$$$, the similar pairs are $$$(5, 2)$$$, $$$(3, 4)$$$, $$$(1, 4)$$$, $$$(1, 3)$$$.
In the final example, all nodes are similar to each other.