Cities

아직 제출이 없습니다시간 제한2초메모리 제한1024 MB

문제

In a far away kingdom, there are NN cities numbered between 00 and N1N - 1. The cities are connected by N1N - 1 two-way roads. Each road has the same length, and connects exactly two cities, such that there is a unique path between any pair of cities.

For any two cities AA and BB, denote by L(A,B)L(A, B) the number of roads of this unique path between cities AA and BB. Given an integer KK, for how many pairs of cities A,BA, B is L(A,B)=KL(A, B) = K?

입력

The sample judge reads input in the following format:

  • line 11: N K
  • line 22: F[0] F[1] .. F[N - 2]
  • line 33: T[0] T[1] .. T[N - 2]

출력

The sample judge will write a single line with the return value of paths(N, K, F, T).

제한

  • 1KN100,0001 \le K \le N \le 100\\,000