#include <bits/stdc++.h>
using namespace std;
long long n, m, a[100001];
bool used[100001], use[100001];
vector<long long> g[100001];
long long dfs(long long v, long long z) {
  if (a[v] == 1)
    z++;
  else
    z = 0;
  if (z > m) {
    return 0;
  }
  long long ans1 = 0, xy = 0;
  ;
  for (long long i = 0; i < g[v].size(); i++) {
    if (!used[g[v][i]]) {
      xy++;
      used[g[v][i]] = true;
      ans1 += dfs(g[v][i], z);
    }
  }
  if (xy == 0)
    return 1;
  else
    return ans1;
}
int main() {
  cin >> n >> m;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (long long i = 1; i < n; i++) {
    long long x, y;
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  used[1] = true;
  long long ans = 0;
  ans += dfs(1, 0);
  cout << ans << endl;
}
