Stevie : "The best part about Christmas is a Christmas tree. Fantastic to play with". A great goalscorer is one who is remembered even years after he left, just like this guy :
You have been given a tree T consisting of N nodes rooted at node 1 and an array A consisting of M distinct integers.
Now, you need to find the number of distinct triplets in tree T such that node V lies in the subtree rooted at node U, and the distance between them is exactly . We call the distance between 2 nodes to be the number of edges lying in the shortest path among them.
2 triplets and are considered to be distinct, if or or .
Can you do it ?
Input Format :
The first line contains 2 space separated integers N and M.
The next line contains M pairwise distinct space separated integers, where the integer denotes .
The next line contains space separated integers, where the integer denotes the parent of node in tree T.
Output Format:
Print a single integer denoting the required number of valid triplets in tree T
Constraints :
, where
The triplets for the sample test are :