#include <bits/stdc++.h>
using namespace std;
const long long N = (long long)(1e5) + 5, mod = (long long)(1e9) + 7;
int n, m, x, y, ans;
vector<vector<int> > vec;
vector<bool> arr, vis;
void dfs(int node, int cnt) {
  int c = 0;
  vis[node] = 1;
  if (cnt > m) return;
  for (auto &i : vec[node])
    if (!vis[i]) c++;
  if (!c) {
    ans++;
  }
  for (auto &i : vec[node]) {
    if (!vis[i]) {
      if (cnt + arr[i] == cnt)
        dfs(i, 0);
      else
        dfs(i, cnt + arr[i]);
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  cin >> n >> m;
  vec.resize(n), vis.resize(n), arr.resize(n);
  for (int i = 0; i < n; i++) cin >> x, arr[i] = x;
  for (int i = 0; i < n - 1; i++) {
    cin >> x >> y;
    vec[x - 1].push_back(y - 1);
    vec[y - 1].push_back(x - 1);
  }
  dfs(0, arr[0]);
  cout << ans << endl;
  return 0;
}
