#include <bits/stdc++.h>
const int MOD = 1e9 + 7;
const int v1 = 1e5 + 5;
using namespace std;
vector<long long> a[200005];
long long n = 0;
long long k = 0;
long long ans = 0;
vector<long long> c;
vector<bool> cat(200005);
bool visited[200005] = {};
void dfs(int count, int s) {
  visited[s] = true;
  if (cat[s])
    count++;
  else
    count = 0;
  if (count > k) return;
  long long term = 0;
  for (int i = 0; i < a[s].size(); ++i) {
    if (visited[a[s][i]] == false) {
      term = 1;
      dfs(count, a[s][i]);
    }
  }
  if (term == 0) {
    ans++;
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  bool t = 0;
  for (long long i = 0; i < n; i++) {
    cin >> t;
    cat[i + 1] = t;
  }
  long long x = 0;
  long long y = 0;
  for (long long i = 0; i < n - 1; i++) {
    cin >> x >> y;
    a[x].push_back(y);
    a[y].push_back(x);
  }
  dfs(0, 1);
  cout << ans;
}
