#include <bits/stdc++.h>
using namespace std;
int pre[100005], cnt;
struct node {
  int u, v, next;
} e[100005 * 2];
int n, m, car[100005];
bool vis[100005];
void addedge(int u, int v) {
  e[cnt].u = u;
  e[cnt].v = v;
  e[cnt].next = pre[u];
  pre[u] = cnt++;
}
int dfs(int u, int d) {
  vis[u] = true;
  if (!car[u]) d = m;
  int ret = 0, flag = 1;
  for (int i = pre[u]; i != -1; i = e[i].next) {
    int v = e[i].v;
    if (!vis[v]) {
      flag = 0;
      if (d >= car[v]) {
        ret += dfs(v, d - car[v]);
      }
    }
  }
  if (flag) ret = flag;
  return ret;
}
int main() {
  cnt = 0;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &car[i]);
  memset(pre, -1, sizeof(pre));
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    addedge(u, v);
    addedge(v, u);
  }
  memset(vis, false, sizeof(vis));
  printf("%d\n", dfs(1, m - car[1]), 0);
  return 0;
}
