#include <bits/stdc++.h>
using namespace std;
int x, y, n, k, ans, cats[100009];
vector<int> g[100009];
bool v[100009];
void dfs(int node, int cat) {
  v[node] = true;
  if (cats[node])
    cat++;
  else
    cat = 0;
  if (cat > k) return;
  for (int i = 0; i < g[node].size(); i++)
    if (!v[g[node][i]]) dfs(g[node][i], cat);
  if (g[node].size() == 1 && node != 1) ans++;
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%d", &cats[i]);
  for (int i = 0; i < n - 1; i++) {
    scanf("%d%d", &x, &y);
    g[x].push_back(y);
    g[y].push_back(x);
  }
  dfs(1, 0);
  printf("%d", ans);
  return 0;
}
