#include <bits/stdc++.h>
using namespace std;
const int INF = (int)1e9 + 7;
int n, k;
int coloring[(int)1e5];
vector<int> G[(int)1e5];
int parent[(int)1e5];
int ans = 0;
void dfs(int u, int c) {
  if (coloring[u] == 0)
    c = 0;
  else
    c++;
  if (c > k) return;
  bool child = true;
  for (int v : G[u]) {
    if (parent[u] != v) {
      parent[v] = u;
      child = false;
      dfs(v, c);
    }
  }
  if (child) ans++;
}
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> coloring[i];
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  dfs(0, 0);
  cout << ans << endl;
  return 0;
}
