#include <bits/stdc++.h>
using namespace std;
using vi = vector<long long int>;
using vvi = vector<vi>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vld = vector<long double>;
using pii = pair<long long int, long long int>;
using psi = pair<string, long long int>;
using pci = pair<char, long long int>;
using vpii = vector<pii>;
long long int mod = 1e9 + 7;
long long int const maxn = 1e5 + 5;
long long int const inf = 1e18;
long long int add(long long int a, long long int b) {
  return ((a % mod) + (b % mod)) % mod;
}
long long int mul(long long int a, long long int b) {
  return ((a % mod) * (b % mod)) % mod;
}
long long int powm(long long int x, long long int n, long long int M) {
  long long int result = 1;
  while (n > 0) {
    if (n % 2 == 1) result = (result * x) % M;
    if (n < 2) break;
    x = (x * x) % M;
    n = n / 2;
  }
  return result;
}
long long int modinverse(long long int a, long long int m) {
  return powm(a, m - 2, m);
}
bool prime(long long int x) {
  if (x <= 1) return false;
  for (int i = 2; i <= sqrt(x); i++)
    if (x % i == 0) return false;
  return true;
}
vi divisor(long long int x) {
  long long int cnt = 0;
  vi v;
  for (long long int i = 1; i <= sqrt(x); i++) {
    if (x % i == 0) {
      if (i != x / i) {
        v.push_back(i);
        v.push_back(x / i);
      } else
        v.push_back(max(i, x / i));
    }
  }
  return v;
}
vector<long long int> sieve(long long int n) {
  bool prim[n + 1];
  memset(prim, true, sizeof(prim));
  for (long long int p = 2; p * p <= n; p++) {
    if (prim[p] == true) {
      for (int i = p * p; i <= n; i += p) prim[i] = false;
    }
  }
  vector<long long int> v;
  for (int i = 2; i <= n; i++)
    if (prim[i]) v.push_back(i);
  return v;
}
vvi adj(maxn);
long long int n, m;
vb vis(maxn);
long long int ans = 0;
vi a(maxn);
long long int cnt = 0;
void dfs(long long int v, long long int pr, long long int k) {
  if (k > m) return;
  int cnt = 1;
  for (int i = 0; i < (long long int)adj[v].size(); i++) {
    if (adj[v][i] != pr) {
      cnt = 0;
      dfs(adj[v][i], v, k * a[adj[v][i]] + a[adj[v][i]]);
    }
  }
  ans += cnt;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long int t;
  t = 1;
  while (t--) {
    cin >> n >> m;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 0; i < n - 1; i++) {
      long long int x, y;
      cin >> x >> y;
      adj[x].push_back(y);
      adj[y].push_back(x);
    }
    dfs(1, -1, a[1]);
    cout << ans;
  }
  return 0;
}
