#include <bits/stdc++.h>
const long long MOD = 1e9 + 7;
using namespace std;
vector<vector<long long> > adjlist;
long long n, m;
vector<long long> cats;
unordered_map<long long, bool> visited;
long long dfs(long long node, long long ct) {
  long long ans = 0;
  visited[node] = true;
  bool f = true;
  for (auto &x : adjlist[node]) {
    if (!visited[x]) {
      f = false;
      if ((ct + cats[x]) > m) {
        continue;
      }
      if (cats[x] > 0) {
        ans += dfs(x, cats[x] + ct);
      } else
        ans += dfs(x, 0);
    }
  }
  if (f)
    return 1;
  else
    return ans;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> m;
  adjlist.assign(n, vector<long long>());
  cats.assign(n, 0);
  for (long long i = 0; i < n; i++) {
    cin >> cats[i];
  }
  for (long long i = 0; i < n - 1; i++) {
    long long a, b;
    cin >> a >> b;
    a--;
    b--;
    adjlist[a].push_back(b);
    adjlist[b].push_back(a);
  }
  cout << dfs(0, cats[0]) << "\n";
  return 0;
}
