#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > G;
int n;
int m;
int curCats;
int catCount = 0;
int ans = 0;
vector<int> cats;
vector<bool> visited;
int dfs_timer;
void dfs(int v, int pr) {
  int ok = 1;
  for (int i = 0; i < G[v].size(); i++) {
    if (pr != G[v][i]) {
      ok = 0;
      if (cats[G[v][i]]) cats[G[v][i]] += cats[v];
      if (cats[G[v][i]] <= m) dfs(G[v][i], v);
    }
  }
  ans += ok;
}
void solve() {
  cin >> n;
  cin >> m;
  G.resize(n);
  cats.resize(n);
  visited.resize(n);
  for (int i = 0; i < n; ++i) {
    cin >> cats[i];
  }
  for (int i = 0; i < n - 1; ++i) {
    int x, y;
    cin >> x >> y;
    G[x - 1].push_back(y - 1);
    G[y - 1].push_back(x - 1);
  }
  dfs(0, -1);
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cout.setf(ios::fixed);
  cout.precision(8);
  solve();
  return 0;
}
