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(1000000)

def DFS(tree, cat, pos, prev, isCat, m, count, travel, visit):
    while len(travel) > 0: #perulangan berlanjut selama stack travel tidak kosong
##        print("pos =", pos, "len tree[pos] =",len(tree[pos]), "travel =", travel)
##        print(cat)
        if int(isCat[pos]) and cat[pos] == 0: #jika pada node tersebut ada kucing dan cat[pos] belum pernah diproses
            cat[pos] += int(isCat[pos]) + cat[prev] #maka cat[pos] akan ditambah dengan cat[prev] dimana prev adalah node asal sebelum masuk ke node pos
##            print("cat[pos] =", cat[pos], "cat[prev] =", cat[prev], "isCat[pos] =", isCat[pos], "prev =", prev, "pos =", pos)
        elif not int(isCat[pos]): #menandakan apakah ada kucing atau tidak, untuk mencegah mereset jumlah cat[pos] yang sudah diproses
            cat[pos] = 0
        if cat[pos] <= m: #untuk node yang belum menemui cat berturut-turut melebihi m
            if len(tree[pos]) == 1 and pos != 0 and visit[pos] == 0: #pengecekan apakah node leaf atau root ataukah node sudah pernah dikunjungi
##                print("pos =", pos, "len tree[pos] =", len(tree[pos]), "count =", count)
                count += 1 #jika node merupakan leaf maka count akan ditambah
                travel.pop() #pop data dari stack travel
                visit[pos] = 1 #menandai node sudah pernah dikunjungi
                prev = pos #mengubah posisi awal sebelum search berpindah
                pos = travel[len(travel) - 1] #perpindahan posisi pos pada tree
            else:
                index = 0 #index untuk diambil node selanjutnya
                if len(tree[pos]) > 0: #dibatasi seperti ini untuk mencegah index out of range karena
                    if tree[pos][index] == prev:
                        tree[pos].pop(0) #akan dipop data tree jika sudah pernah dikunjungi
                if len(tree[pos]) > 0:
                    travel += [tree[pos][index]] #jika belum pernah dikunjungi maka akan ditambah ke stack
                    visit[pos] = 1 #menandai node sudah pernah dikunjungi
                    prev = pos
                    pos = travel[len(travel) - 1]
                else:
                    travel.pop()
                    if len(travel) > 0:
                        prev = pos
                        pos = travel[len(travel) - 1]
        else: #untuk node yang menemui cat berturut-turut lebih dari m
            travel.pop()
            if len(travel) > 0:
                prev = pos
                pos = travel[len(travel) - 1]
##    print("pos =", pos, "len tree[pos] =", len(tree[pos]), "count =", count, end=' ')
##    if int(isCat[pos]):
##        cat += int(isCat[pos])
##    else:
##        cat = 0
####    print("cat =", cat)
##    if cat <= m:
##        if len(tree[pos]) == 1 and pos != 0:
##            count += 1
##        else:
##            for i in range(len(tree[pos])):
##                if tree[pos][i] != prev:
##                    count = DFS(tree, cat, tree[pos][i], pos, isCat, m, count)
    return count

line = input().split()
n = int(line[0])
m = int(line[1])
##limit = n - 1
tree = []
##visit = [0] * n
for i in range(n):
    tree.append([]) #inisialisasi tree
visit = [0]*n #menyimpan node yang belum dikunjingi
isCat = input().split() #menyimpan ada tidaknya cat pada node
count = 0
travel = [0] #stack untuk DFS
cat = [0]*n #array untuk menyimpan berapa banyak cat berturut pada posisi tersebut
for i in range(n-1):
    xy = input().split()
    tree[int(xy[0]) - 1].append(int(xy[1]) - 1) #proses pembuatan tree dengan edgenya
    tree[int(xy[1]) - 1].append(int(xy[0]) - 1)
##print(tree)
count = DFS(tree, cat, 0, 0, isCat, m, count, travel, visit)

##path = [0]
##pos = 0
##prev = 0
####print(tree)
##while len(path) > 0:
####    print(pos+1)
####    if pos == limit:
####        count += 1
####        break
##    if int(isCat[pos]) and cat[pos] == 0:
##        cat[pos] += 1 + cat[prev]
####    print(pos+1, "cat =",cat, "count =", count, "visit pos =", visit[pos])
##    if len(tree[pos]) > 0 and cat[pos] <= m:
##        path += [tree[pos][0]]
##        tree[pos].pop(0)
##        visit[pos] = 1
##        prev = pos
##        pos = path[len(path) - 1]
##    elif cat[pos] > m:
##        visit[pos] = 1
##        path.pop()
##        if len(path) > 0:
##            prev = pos
##            pos = path[len(path) - 1]
##    else:
####        print(pos+1)
##        if visit[pos] == 0 and cat[pos] <= m:
##            count += 1
##        visit[pos] = 1
##        path.pop()
##        if len(path) > 0:
##            prev = pos
##            pos = path[len(path) - 1]
##
print(count)
##input()