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.

Input

The first line contains two integers, n and m (2 ≤ n ≤ 105, 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 a1, a2, ..., an, where each ai 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 "xi yi" (without the quotes) (1 ≤ xi, yi ≤ n, xi ≠ yi), where xi and yi are the vertices of the tree, connected by an edge. 

It is guaranteed that the given set of edges specifies a tree.

Output

A single integer — the number of distinct leaves of a tree the path to which from Kefa's home contains at most m consecutive vertices with cats.

Examples

Input

4 1
1 1 0 0
1 2
1 3
1 4


Output

2


Input

7 1
1 0 1 1 0 0 0
1 2
1 3
2 4
2 5
3 6
3 7


Output

2

Note

Let us remind you that a tree is a connected graph on n vertices and n - 1 edge. A rooted tree is a tree with a special vertex called root. In a rooted tree among any two vertices connected by an edge, one vertex is a parent (the one closer to the root), and the other one is a child. A vertex is called a leaf, if it has no children.

Note to the first sample test: <image> The vertices containing cats are marked red. The restaurants are at vertices 2, 3, 4. Kefa can't go only to the restaurant located at vertex 2.

Note to the second sample test: <image> The restaurants are located at vertices 4, 5, 6, 7. Kefa can't go to restaurants 6, 7.
import sys
sys.setrecursionlimit(10**6)

# class Edge:
#     def __init__(self, from_vertex, to_vertex, weight=0):
#         self.from_vertex = from_vertex
#         self.to_vertex = to_vertex
#         self.weight = weight
#
#     def get_from(self):
#         return self.from_vertex
#
#     def get_to(self):
#         return self.to_vertex
#
#     def get_weight(self):
#         return self.weight
#
#     def __str__(self):
#         return str("{v} -> {w} : {weight}".
#                    format(v=self.from_vertex, w=self.to_vertex, weight=self.weight))


class Graph:
    def __init__(self, num_vertex):
        self.num_vertex = num_vertex
        self.adj_list = [[] for i in range(num_vertex)]
        self.indegree = [0 for i in range(num_vertex)]

    def __len__(self):
        return self.num_vertex

    def add_edge(self, v, w):
        self.adj_list[v].append(w)
        self.adj_list[w].append(v)



        self.indegree[w] += 1

    def adj(self, vertex):
        return self.adj_list[vertex]

    def get_indegree(self, vertex):
        return self.indegree[vertex]
#
#
#
#
#
#
# def dfs(graph, v, marked):
#     marked[v] = True
#     for e in graph.adj(v):
#         w = e.get_to()
#         if not marked[w]:
#             dfs(graph, w, marked)
#
#
#

def bfs(graph, v, marked, cat_list):
    queue = [v]
    marked[v] = True
    consecutive_cats_met = [-1 for i in range(graph.num_vertex)]
    consecutive_cats_met[v] = cat_list[v]
    while queue:
        v = queue.pop(0)
        for w in graph.adj(v):
            if not marked[w]:
                if cat_list[v] == 1:
                    consecutive_cats_met[w] = consecutive_cats_met[v] + cat_list[w]
                else:
                    consecutive_cats_met[w] = cat_list[w]

                if consecutive_cats_met[w] <= num_cat_limit:
                    queue.append(w)
                    marked[w] = True
                else:
                    marked[w] = True




    return consecutive_cats_met


def get_leaves(graph):
    leaves = []
    for v in range(graph.num_vertex):
        if len(graph.adj(v)) == 1:
            leaves.append(v)
    return leaves


# utilities for matrix processing
# def to_index(row, col):
#     return row * width + col
#
# def has_left(row, col):
#     return col != 0
# def has_right(row, col):
#     return col != width - 1
# def has_above(row, col):
#     return row != 0
# def has_below(row, col):
#     return row != height - 1
#
# def is_rear(idx):
#     return idx % width == 0 or (idx+1) % width == 0\
#            or idx < width or idx > height*width - width
#
#
# def connect(world_map, s_row, s_col, t_row, t_col):
#
#     s_cell = world_matrix[s_row][s_col]
#     t_cell = world_matrix[t_row][t_col]
#     s_idx = to_index(s_row, s_col)
#     t_idx = to_index(t_row, t_col)
#     if s_cell == t_cell:
#         world_map.add_edge(s_idx, t_idx)
#
#     elif s_cell == '@' and t_cell == '.':
#         world_map.add_edge(s_idx, t_idx)
#
#     elif t_cell == '@' and s_cell == '.':
#         world_map.add_edge(s_idx, t_idx)






num_cat_limit = 0


def main():
    global  num_cat_limit
    num_parks, num_cat_limit = map(int, input().rstrip().split(' '))
    cat_list = list(map(int, input().rstrip().split(' ')))
    parks = Graph(num_parks)
    for i in range(num_parks - 1):
        v, w = map(int, input().rstrip().split(' '))
        parks.add_edge(v - 1, w - 1)

    marked = [False] * num_parks
    consecutive_cats_met = bfs(parks, 0, marked, cat_list)

    leaves = get_leaves(parks)

    count = 0
    for leaf in leaves:
        if leaf == 0: continue
        if consecutive_cats_met[leaf] <= num_cat_limit and consecutive_cats_met[leaf] != -1:
            count += 1

    print(count)








if __name__ == '__main__':
    main()



