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.
from collections import defaultdict, deque
from itertools import count

class Node:
    def __init__(self, id, cat):
        self.id = id
        self.cat = cat
        self.children = []
        self.explored = False
        self.i = 0

    def __iter__(self):
        return self

    def __repr__(self):
        # return str((self.id, self.cat, [child.id for child in self.children]))
        return 'ID:{}'.format(self.id)

    @property
    def nb_child(self):
        return len(self.children)

    def next(self):
        try:
            child = self.children[self.i]
            self.i += 1
        except IndexError:
            raise StopIteration
        else:
            return child

def do_dfs(root, m):
    """Do an iterative version of dfs()

    Parameters
    ----------
    root : root node of the dfs
    m : maximum number of cats

    """
    E1, E2 = 'E1', 'E2'

    S = deque()
    S.appendleft([[root, False, 0, 0], E1])
    while S:
        # print S
        data, entry_point = S.popleft()

        if entry_point == E1:
            node, active, longest_chain, incoming_chain = data # unpack arguments

            current_chain = incoming_chain+1 if node.cat else 0
            new_longest = max(current_chain, longest_chain)
            if not node.children: # base case
                RETVAL = new_longest <= m
            else: # recursive case
                nb_legal = i = 0
                child = node.children[i]
                S.appendleft([[node, active, longest_chain, incoming_chain, current_chain, new_longest, nb_legal, i], E2])
                S.appendleft([(child, node.cat, new_longest, current_chain), E1])
        elif entry_point == E2:
            node, active, longest_chain, incoming_chain, current_chain, new_longest, nb_legal, i = data

            nb_path = RETVAL
            nb_legal += nb_path
            i += 1
            if i == node.nb_child: # end of while loop
                RETVAL = nb_legal
            else: # continuation of while loop
                child = node.children[i]
                S.appendleft([[node, active, longest_chain, incoming_chain, current_chain, new_longest, nb_legal, i], E2])
                S.appendleft([(child, node.cat, new_longest, current_chain), E1])

    return RETVAL

def dfs(node, active, longest_chain, incoming_chain):
    """Perform a modified dfs on node

    Parameters
    ----------
    node : the node in question
    active : True if the parent of `node` has a cat
    longest_chain : longest chain of cats among parents of `node`
    incoming_chain : length of incoming chain of cats (0 if parent of `node`
    does not have a cat)

    """
# E1
    # debug_str = 'dfs(node={}, active={}, longest_chain={}, incoming_chain={}'
    # print debug_str.format(node.id, active, longest_chain, incoming_chain)

    current_chain = incoming_chain+1 if node.cat else 0
    new_longest = max(current_chain, longest_chain)
    if not node.children:
        return new_longest <= m
    else:
        nb_legal = 0
        i = 0
        while i < node.nb_child:
            child = node.children[i]
            nb_path = dfs(node=child, active=node.cat, longest_chain=new_longest, incoming_chain=current_chain)
# E2
            nb_legal += nb_path
            i += 1

        return nb_legal

if __name__ == '__main__':
    n, m = [int(num) for num in raw_input().split()]
    C = [int(num) for num in raw_input().split()]
    E = [[int(num) for num in raw_input().split()] for _ in range(n-1)]

    v_ids = set(v for v1, v2 in E for v in [v1, v2])
    V = {v_id: Node(v_id, bool(c)) for v_id, c in zip(sorted(v_ids), C)}

    G = defaultdict(list)
    for v1, v2 in E:
        G[v1].append(v2)
        G[v2].append(v1)

    T = defaultdict(list)
    Q = deque()
    Q.appendleft(1)
    F = {1: True}

    C = dict(zip(count(start=1), C))
    while Q:
        node_id = Q.popleft()
        del F[node_id]
        V[node_id].explored = True

        for neighbor in G[node_id]:
            if not V[neighbor].explored and neighbor not in F:
                V[node_id].children.append(V[neighbor]) # update children
                Q.appendleft(neighbor) # add to frontier
                F[neighbor] = True

    # print dfs(node=V[1], active=False, longest_chain=0, incoming_chain=0)
    print do_dfs(root=V[1], m=m)
