#include <bits/stdc++.h>
using namespace std;
bool c[100010], vis[100010];
vector<int> adj[100010];
int n, m, u, v;
int slv(int node, int par, int cats) {
  if (c[node])
    cats++;
  else
    cats = 0;
  if (cats > m) return 0;
  if (adj[node].size() == 1 && node != 1) return 1;
  int ans = 0;
  for (int i = 0; i < adj[node].size(); i++) {
    if (adj[node][i] != par) ans += slv(adj[node][i], node, cats);
  }
  return ans;
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> c[i];
  for (int i = 1; i < n; i++) {
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  cout << slv(1, -1, 0) << endl;
}
