#include <bits/stdc++.h>
using namespace std;
std::vector<int> edge[100005];
int color[100005];
int bfs(int n, int ok) {
  std::vector<int> vis(100005, 0);
  vis[1] = 1;
  queue<int> q;
  q.push(1);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int x : edge[u]) {
      if (vis[x] == 0) {
        if (color[x] == 0 and color[u] > ok)
          color[x] = color[u];
        else if (color[x] == 1) {
          color[x] += color[u];
        }
        vis[x] = 1;
        q.push(x);
      }
    }
  }
  int ans = 0;
  for (int i = 2; i <= n; i++) {
    if ((int)edge[i].size() == 1 and color[i] <= ok) {
      ans++;
    }
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  int n, ok;
  cin >> n >> ok;
  for (int i = 1; i <= n; i++) {
    cin >> color[i];
  }
  for (int i = 1; i <= n - 1; i++) {
    int u, v;
    cin >> u >> v;
    edge[u].push_back(v);
    edge[v].push_back(u);
  }
  cout << bfs(n, ok) << '\n';
  return 0;
}
