#include <bits/stdc++.h>
using namespace std;
bool val[100005], viz[100005];
int nr[100005], cnt, n, m;
vector<int> lst[100005];
void dfs(int nod, int p) {
  bool leaf = true;
  viz[nod] = true;
  if (p + val[nod] > m) return;
  if (val[nod] == 0) p = 0;
  for (int i = 0; i < lst[nod].size(); ++i) {
    if (!viz[lst[nod][i]]) {
      dfs(lst[nod][i], p + val[nod]);
      leaf = false;
    }
  }
  if (leaf) ++cnt;
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) cin >> val[i];
  for (int a, b, i = 1; i < n; ++i) {
    cin >> a >> b;
    lst[a].push_back(b);
    lst[b].push_back(a);
  }
  dfs(1, 0);
  cout << cnt;
  return 0;
}
