#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, k, a, b, c, mx, x[N], vis[N];
vector<int> adj[N];
void dfs(int u, int c) {
  if (x[u]) {
    c++;
  } else {
    c = 0;
  }
  if (c > k) {
    return;
  }
  bool salka = true;
  vis[u] = 1;
  for (int v : adj[u]) {
    if (!vis[v]) {
      salka = false;
      dfs(v, c);
    }
  }
  mx += salka;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> x[i];
  }
  for (int i = 1; i < n; i++) {
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  dfs(1, 0);
  cout << mx << endl;
  return 0;
}
