#include <bits/stdc++.h>
using namespace std;
vector<int> v[100000];
int n, k, c[100001], vis[100000], x, y, l = 0;
void dfs(vector<int> v[], int u, int p) {
  vis[u] = 1;
  if (c[u])
    p++;
  else
    p = 0;
  if (p > k) return;
  if (v[u].size() == 1 && u != 1) {
    l++;
  }
  for (int i = 0; i < v[u].size(); i++)
    if (vis[v[u][i]] == 0) dfs(v, v[u][i], p);
}
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> c[i];
  for (int i = 0; i < n - 1; i++) {
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  dfs(v, 1, 0);
  cout << l;
}
