Kefa decided to celebrate his first big salary by going to the restaurant. 

He lives by an unusual park. The park is a rooted tree consisting of *n* vertices with the root at vertex 1. Vertex 1 also contains Kefa's house. Unfortunaely for our hero, the park also contains cats. Kefa has already found out what are the vertices with cats in them.

The leaf vertices of the park contain restaurants. Kefa wants to choose a restaurant where he will go, but unfortunately he is very afraid of cats, so there is no way he will go to the restaurant if the path from the restaurant to his house contains more than *m* consecutive vertices with cats. 

Your task is to help Kefa count the number of restaurants where he can go.
The first line contains two integers, *n* and *m* (2 ≤ *n* ≤ 10<sup class="upper-index">5</sup>, 1 ≤ *m* ≤ *n*) — the number of vertices of the tree and the maximum number of consecutive vertices with cats that is still ok for Kefa.

The second line contains *n* integers *a*<sub class="lower-index">1</sub>, *a*<sub class="lower-index">2</sub>, ..., *a*<sub class="lower-index">*n*</sub>, where each *a*<sub class="lower-index">*i*</sub> either equals to 0 (then vertex *i* has no cat), or equals to 1 (then vertex *i* has a cat).

Next *n* - 1 lines contains the edges of the tree in the format "*x*<sub class="lower-index">*i*</sub> *y*<sub class="lower-index">*i*</sub>" (without the quotes) (1 ≤ *x*<sub class="lower-index">*i*</sub>, *y*<sub class="lower-index">*i*</sub> ≤ *n*, *x*<sub class="lower-index">*i*</sub> ≠ *y*<sub class="lower-index">*i*</sub>), where *x*<sub class="lower-index">*i*</sub> and *y*<sub class="lower-index">*i*</sub> are the vertices of the tree, connected by an edge. 

It is guaranteed that the given set of edges specifies a tree.
def dfs(node, parent, consecutive_cats, cats, adjacency_list, m):
    # 判断当前节点是否有猫
    if cats[node - 1] == 1:  # 节点编号从1开始，而列表索引从0开始
        consecutive_cats += 1
    else:
        consecutive_cats = 0

    # 如果连续猫的数量超过m，该路径不可行
    if consecutive_cats > m:
        return 0

    # 判断当前节点是否是叶子节点
    # 叶子节点的特点是在邻接列表中只有一个相邻节点
    # 但是根节点是个例外，因为它可能只与一个节点相连，但我们不算它为叶子节点
    if len(adjacency_list[node]) == 1 and node != 1:
        return 1

    result = 0
    # 遍历当前节点的所有子节点
    for child in adjacency_list[node]:
        # 避免返回到上一个节点
        if child != parent:
            # 递归探索子节点
            result += dfs(child, node, consecutive_cats, cats, adjacency_list, m)

    return result

def main():
    # 读取n和m
    n, m = map(int, input().split())
    # 读取每个节点是否有猫的信息
    cats = list(map(int, input().split()))

    # 初始化邻接列表
    adjacency_list = {i: [] for i in range(1, n+1)}

    # 填充邻接列表
    for _ in range(n-1):
        x, y = map(int, input().split())
        adjacency_list[x].append(y)
        adjacency_list[y].append(x)  # 这是一个无向树，所以x到y和y到x都是有效的连接

    # 从Kefa的家开始执行DFS并输出结果
    print(dfs(1, -1, 0, cats, adjacency_list, m))

if __name__ == "__main__":
    main()
