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.
MAX_N = 10**5 + 3

m = 0
tem_gato = [False] * MAX_N
lista_adjacencia = [[] for _ in range(MAX_N)]
resultado = 0
maximo_x = [0] * MAX_N
atual = [0] * MAX_N

def dfs(no, pai=0):
    global resultado
    if tem_gato[no]:
        atual[no] = 1 + (atual[pai] if tem_gato[pai] else 0)
    else:
        atual[no] = 0

    maximo_x[no] = max(atual[no], maximo_x[pai])

    eh_folha = True

    for vizinho in lista_adjacencia[no]:
        if vizinho != pai:
            dfs(vizinho, no)
            eh_folha = False

    if eh_folha and maximo_x[no] <= m:
        resultado += 1

if __name__ == "__main__":
    # freopen("in.txt", "r", stdin)

    n, m = map(int, input().split())

    entrada_gatos = list(map(int, input().split()))

    for i in range(1, n+1):
        tem_gato[i] = entrada_gatos[i-1]

    u, v = 0, 0

    for i in range(1, n):
        u, v = map(int, input().split())
        lista_adjacencia[u].append(v)
        lista_adjacencia[v].append(u)

    resultado = 0
    dfs(1)

    print(resultado)
