Monkeys

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

문제

Given is a tree with NN vertices. There are KK monkeys in the tree. The monkeys want to occupy some vertices of the tree so that each monkey is in some vertex and each vertex contains at most one monkey. Then, they want to remove some edges of the tree so that each monkey can still move to at least one other monkey using only the remaining edges.

Your task is to find the minimum possible number of remaining edges.

입력

The first line of input contains an integer TT, the number of test cases (1T1001 \le T \le 100).

Each test case begins with a line containing two integers NN and KK (2KN1052 \le K \le N \le 10^5). The next line contains N1N - 1 space-separated integers a_1,a_2,,a_N1a\_1, a\_2, \ldots, a\_{N - 1} (1a_ii1 \le a\_i \le i). They mean that, for each ii, there is an edge between vertex a_ia\_i and vertex i+1i + 1.

출력

For each test case, print the minimum possible number of remaining edges.