#include <bits/stdc++.h>
using namespace std;
mt19937 rng(time(0));
uniform_int_distribution<int> uid(-1e9, 1e9);
vector<int> g[100009];
int res, v[100009], m, d[100009];
void dfs(int x, int px, int y) {
  d[x] = d[px] * v[x] + v[x];
  for (auto& i : g[x])
    if (i != px) dfs(i, x, y & (d[x] <= m));
  if (x && g[x].size() == 1) res += y & (d[x] <= m);
}
signed main() {
  int n, x, y;
  cin >> n >> m;
  for (int i = 0; i < n; ++i) cin >> v[i];
  for (int i = 0; i < n - 1; ++i) {
    cin >> x >> y;
    g[--x].push_back(--y);
    g[y].push_back(x);
  }
  dfs(0, 0, 1);
  cout << res;
}
