#include <bits/stdc++.h>
using namespace std;
int a[200005];
int m = 0;
vector<int> vec[200005];
int vis[200005];
int ct = 0;
void dfs(int r, int c) {
  vis[r] = 1;
  int f = 0;
  if (a[r] == 1)
    c++;
  else
    c = 0;
  if (c > m) return;
  for (int h = 0; h < vec[r].size(); h++) {
    int vl = vec[r][h];
    if (!vis[vl]) {
      f = 1;
      dfs(vl, c);
    }
  }
  if (f == 0) {
    ct++;
  }
  return;
}
int main() {
  int n;
  cin >> n >> m;
  for (int h = 1; h <= n; h++) {
    cin >> a[h];
  }
  int u, v;
  for (int h = 0; h < n - 1; h++) {
    cin >> u >> v;
    vec[u].push_back(v);
    vec[v].push_back(u);
  }
  dfs(1, 0);
  cout << ct << endl;
}
