#include <bits/stdc++.h>
using namespace std;
int n, m;
bool cat[100005];
bool visited[100005];
vector<int> tree[100005];
int road = 0;
void dfs(int v, int mao) {
  visited[v] = 1;
  if (mao > m) return;
  int l = tree[v].size();
  bool flag = true;
  int w;
  for (int i = 0; i < l; i++) {
    w = tree[v][i];
    if (!visited[w]) {
      flag = false;
      if (cat[w]) {
        dfs(w, mao + 1);
      } else {
        dfs(w, 0);
      }
      visited[w] = 1;
    }
  }
  if (flag) {
    road++;
    return;
  }
}
int main() {
  scanf("%d%d", &n, &m);
  int d;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &d);
    cat[i] = d;
  }
  int u, v;
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &u, &v);
    tree[u].push_back(v);
    tree[v].push_back(u);
  }
  if (cat[1])
    dfs(1, 1);
  else
    dfs(1, 0);
  printf("%d\n", road);
  return 0;
}
