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.
import bisect
import random
import sys
import copy
from collections import defaultdict, deque, Counter
from heapq import heapify, heappop, heappush
from itertools import permutations, accumulate, tee
from functools import lru_cache
from math import gcd, log, sqrt, ceil, floor

# sys.setrecursionlimit(10**6)


def input(): return sys.stdin.readline().rstrip()
def mi(): return map(int, input().split())
def li(): return list(mi())


def pairwise(iterable):
    "s -> (s0,s1), (s1,s2), (s2, s3), ..."
    a, b = tee(iterable)
    next(b, None)
    return zip(a, b)

def fractionMod(a, b, p):  # a/b mod p
    return ((a % p) * pow(b, p-2, p)) % p


def mlist(n_dims, default=0):
    empty_list = default
    for n in n_dims:
        empty_list = [copy.deepcopy(empty_list) for _ in range(n)]
    return empty_list


def calcPreSum(s: list):
    return list(accumulate(s, initial=0))


class SegmentTree:
    def __init__(self, n: int):
        self.n = n
        self.size = 4 * n
        self.sum = [0] * self.size
        self.count = [0] * self.size

    def add(self, index: int, val: int):
        self.__add(1, 1, self.n, index, val)

    def __add(self, o: int, l: int, r: int, index: int, val: int):
        if l == r:
            self.sum[o] += val
            self.count[o] += 1
            return

        mid = (l+r) >> 1
        if index <= mid:
            self.__add(o*2, l, mid, index, val)
        else:
            self.__add(o*2+1, mid+1, r, index, val)
        self.sum[o] = self.sum[o*2] + self.sum[o*2+1]
        self.count[o] = self.count[o*2] + self.count[o*2+1]

    def query_sum(self, L: int, R: int) -> int:
        return self.__query(1, 1, self.n, L, R, self.sum)

    def __query(self, o: int, l: int, r: int, L: int, R: int, datas: list):
        if r < L or l > R:
            return 0
        if L <= l and r <= R:
            return datas[o]

        s = 0
        mid = (l+r) >> 1
        if L <= mid:
            s += self.__query(o*2, l, mid, L, R, datas)
        if R >= mid+1:
            s += self.__query(o*2+1, mid+1, r, L, R, datas)
        return s

    def query_count(self, L: int, R: int) -> int:
        return self.__query(1, 1, self.n, L, R, self.count)


class LazySegmentTree:
    def __init__(self, l, r):
        self.l = l
        self.r = r
        self.left = None
        self.right = None
        self.sum = 0
        self.delay = False

    def _update_lazy(self):
        self.delay = 0
        self.left.delay = not self.left.delay
        self.left.sum = self.left.r - self.left.l + 1 - self.left.sum
        self.right.delay = not self.right.delay
        self.right.sum = self.right.r - self.right.l + 1 - self.right.sum

    def update(self, L, R):
        if L <= self.l and self.r <= R:
            self.sum = self.r - self.l + 1 - self.sum
            self.delay = not self.delay
            return

        mid = self.l + ((self.r - self.l) >> 1)
        if self.left is None:
            self.left = LazySegmentTree(self.l, mid)
            self.right = LazySegmentTree(mid+1, self.r)

        if self.delay:
            self._update_lazy()

        if mid >= L:
            self.left.update(L, R)

        if mid + 1 <= R:
            self.right.update(L, R)

        self.sum = self.left.sum + self.right.sum

    def query(self, L, R):
        if L <= self.l and self.r <= R:
            return self.sum

        if self.left is None:
            return self.sum

        mid = self.l + ((self.r - self.l) >> 1)
        if self.delay:
            self._update_lazy()

        ans = 0
        if mid >= L:
            ans += self.left.query(L, R)

        if mid + 1 <= R:
            ans += self.right.query(L, R)

        return ans


class FenwickTree:
    def __init__(self, n):
        self.size = n + 1
        self.datas = [0] * self.size

    def __lowbit(self, x: int) -> int:
        return x & -x

    def add(self, index: int, value: int):
        while index < self.size:
            self.datas[index] += value
            index += self.__lowbit(index)

    def query(self, index: int):
        s = 0
        while index >= 1:
            s += self.datas[index]
            index -= self.__lowbit(index)
        return s

    def sum(self, L: int, R: int):
        return self.query(R) - self.query(L-1)


class Trie:
    def __init__(self):
        self.childs = {}
        self.count = 0

    def append(self, s):
        cur = self
        for i in s:
            if i not in cur.childs:
                cur.childs[i] = Trie()

            cur = cur.childs[i]
            cur.count += 1

    def find(self, s):
        cur = self
        ans = 0
        for i in s:
            if i not in cur.childs:
                break
            cur = cur.childs[i]
            if cur.count <= 1:
                break
            ans += 1
        return ans


class UF:
    def __init__(self, n):
        self.datas = [-1] * n
        self.group_count = n

    def find(self, x):
        px = x
        while self.datas[x] >= 0:
            x = self.datas[x]
        while px != x:
            self.datas[px], px = x, self.datas[px]
        return x

    def merge(self, x, y) -> bool:
        px = self.find(x)
        py = self.find(y)
        if px == py:
            return False

        if self.datas[px] < self.datas[py]:
            self.datas[px] += self.datas[py]
            self.datas[py] = px
        else:
            self.datas[py] += self.datas[px]
            self.datas[px] = py
        self.group_count -= 1
        return True


def solve():
    n, m = mi()
    cats = li()
    cats = [0] + cats
    e = defaultdict(list)
    for _ in range(n-1):
        x, y = mi()
        e[x].append(y)
        e[y].append(x)
        
        
    def dfs(i, parent, cat):
        if cats[i] == 1:
            cat += 1
            if cat > m:
                return 0
        else:
            cat = 0
        if len(e[i]) == 1:
            return 1 if cat <= m else 0
        
        ans = 0
        for j in e[i]:
            if j != parent:
                ans += dfs(j, i, cat)
        return ans
    ans = dfs(1, -1, 0)
    print(ans)


solve()
