#include <bits/stdc++.h>
using namespace std;
int output = 0;
int N, consCats;
vector<int> adj[999999];
int vCats[999999];
bool visited[999999];
bool leafs[999999];
bool aux;
void deep(int s, bool visited[], vector<int> adj[], int consCats, int var,
          int vCats[]);
int main() {
  cin >> N >> consCats;
  for (int i = 1; i <= N; i++) {
    visited[i] = false;
    leafs[i] = false;
  }
  int cat;
  for (int i = 1; i <= N; i++) {
    cin >> cat;
    vCats[i] = cat;
  }
  for (int i = 1; i < N; i++) {
    int x, y;
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  deep(1, visited, adj, consCats, 0, vCats);
  cout << output;
  return 0;
}
void deep(int s, bool visited[], vector<int> adj[], int consCats, int var,
          int vCats[]) {
  if (visited[s]) return;
  visited[s] = true;
  aux = true;
  for (int i = 0; i < adj[s].size(); i++) {
    if (visited[adj[s][i]] == false) {
      aux = false;
      break;
    }
  }
  (aux) ? leafs[s] = true : leafs[s] = false;
  vCats[s] ? var += vCats[s] : var = 0;
  if (leafs[s] && var <= consCats) {
    output++;
    return;
  }
  for (auto u : adj[s]) {
    if (var > consCats)
      continue;
    else
      deep(u, visited, adj, consCats, var, vCats);
  }
}
