input
4 1 1 2 3 4 1 2 2 3 3 4 1 4 4
out
4
被 Hack 的题解:https://www.luogu.com.cn/blog/yangkai/p2633-count-on-a-tree