E. Mirror I
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

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.

Input

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

Output exactly one integer, the number of distinct unordered pairs of similar nodes.

Examples
Input
5 2
1 2 2 4
Output
4
Input
5 5
1 2 3 4
Output
0
Input
4 4
1 1 1
Output
0
Input
4 1
1 1 1
Output
6
Note

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.