Kefa decided to celebrate his first big salary by going to the restaurant. 

He lives by an unusual park. The park is a rooted tree consisting of n vertices with the root at vertex 1. Vertex 1 also contains Kefa's house. Unfortunaely for our hero, the park also contains cats. Kefa has already found out what are the vertices with cats in them.

The leaf vertices of the park contain restaurants. Kefa wants to choose a restaurant where he will go, but unfortunately he is very afraid of cats, so there is no way he will go to the restaurant if the path from the restaurant to his house contains more than m consecutive vertices with cats. 

Your task is to help Kefa count the number of restaurants where he can go.

Input

The first line contains two integers, n and m (2 ≤ n ≤ 105, 1 ≤ m ≤ n) — the number of vertices of the tree and the maximum number of consecutive vertices with cats that is still ok for Kefa.

The second line contains n integers a1, a2, ..., an, where each ai either equals to 0 (then vertex i has no cat), or equals to 1 (then vertex i has a cat).

Next n - 1 lines contains the edges of the tree in the format "xi yi" (without the quotes) (1 ≤ xi, yi ≤ n, xi ≠ yi), where xi and yi are the vertices of the tree, connected by an edge. 

It is guaranteed that the given set of edges specifies a tree.

Output

A single integer — the number of distinct leaves of a tree the path to which from Kefa's home contains at most m consecutive vertices with cats.

Examples

Input

4 1
1 1 0 0
1 2
1 3
1 4


Output

2


Input

7 1
1 0 1 1 0 0 0
1 2
1 3
2 4
2 5
3 6
3 7


Output

2

Note

Let us remind you that a tree is a connected graph on n vertices and n - 1 edge. A rooted tree is a tree with a special vertex called root. In a rooted tree among any two vertices connected by an edge, one vertex is a parent (the one closer to the root), and the other one is a child. A vertex is called a leaf, if it has no children.

Note to the first sample test: <image> The vertices containing cats are marked red. The restaurants are at vertices 2, 3, 4. Kefa can't go only to the restaurant located at vertex 2.

Note to the second sample test: <image> The restaurants are located at vertices 4, 5, 6, 7. Kefa can't go to restaurants 6, 7.
#include <bits/stdc++.h>
using namespace std;
const double pi = 3.14159;
long long int size_;
long long int intsum;
bitset<10000010> bs;
vector<long long int> primes;
long long int NODENUM = 0;
const long long int NN = 1e5 + 5;
void printint(long long int k) { printf("%lld ", k); }
void printallint(vector<long long int> k) {
  for_each(k.begin(), k.end(), printint);
}
void printallvecint(vector<vector<long long int> > k) {
  for_each(k.begin(), k.end(), printallint);
  printf("\n");
}
void printchar(char k) { printf("%c ", k); }
void printallchar(vector<char> k) { for_each(k.begin(), k.end(), printchar); }
void printstring(string k) {
  cout << k;
  printf("\n");
}
void printpairIS(pair<long long int, string> k) {
  cout << k.first << " " << k.second << endl;
}
void printnode(vector<long long int> NODE) {
  printf("%lld : ", NODENUM++);
  for_each(NODE.begin(), NODE.end(), printint);
  printf("\n");
}
void printgraph(vector<vector<long long int> > G) {
  for_each(G.begin(), G.end(), printnode);
  NODENUM = 0;
  printf("\n");
}
bool iseven(long long int k) { return (k % 2 == 0) ? true : false; }
bool isodd(long long int k) { return (k % 2 != 0) ? true : false; }
bool paircompare(pair<int, string> k, pair<int, string> f) {
  return k.first < f.first;
}
void intsumming(long long int k) { intsum += k; }
bool pairCompare(const pair<long long int, long long int> firstElem,
                 const pair<long long int, long long int> secondElem) {
  return firstElem.second < secondElem.second;
}
void printpair(pair<long long int, long long int> p) {
  printf("%lld , %lld\t", p.first, p.second);
}
void revsort(vector<long long int>& k) {
  sort(k.begin(), k.end());
  reverse(k.begin(), k.end());
}
void tolowerf(char& k) {
  if (isupper(k)) k = k + 32;
}
void toupperf(char& k) {
  if (islower(k)) k = k - 32;
}
void strtolower(string& k) { for_each(k.begin(), k.end(), tolowerf); }
void strtupper(string& k) { for_each(k.begin(), k.end(), toupperf); }
long long int gcd(long long int a, long long int b) {
  return b == 0 ? a : gcd(b, a % b);
}
long long int lcm(long long int a, long long int b) {
  return a * b / gcd(a, b);
}
void sieve(long long int f) {
  size_ = f + 1;
  bs.set();
  bs[0] = bs[1] = 0;
  for (long long int i = 2; i <= size_; i++)
    if (bs[i]) {
      for (long long int j = i * i; j <= size_; j += i) bs[j] = 0;
      primes.push_back(i);
    }
}
bool isprime(long long int N) {
  if (N <= size_) return bs[N];
  for (long long int k = 0; k < primes.size(); k++)
    if (N % primes[k] == 0) return 0;
  return true;
}
vector<long long int> primefactors(long long int N) {
  vector<long long int> factors;
  long long int indexofPF = 0, PF = primes[indexofPF];
  while (PF * PF <= N) {
    while (N % PF == 0) {
      N /= PF;
      factors.push_back(PF);
    }
    PF = primes[++indexofPF];
  }
  if (N != 1) factors.push_back(N);
  return factors;
}
long long int Numdiv(long long int N) {
  long long int indexofPF = 0, PF = primes[indexofPF];
  long long int ANS = 1;
  while (PF * PF <= N) {
    long long int power = 0;
    while (N % PF == 0) {
      N /= PF;
      power++;
    }
    ANS *= (power + 1);
    PF = primes[++indexofPF];
  }
  if (N != 1) ANS *= 2;
  return ANS;
}
struct segTree {
  long long int n;
  vector<long long int> t;
  segTree(vector<long long int> a) {
    n = a.size();
    t.resize(n * 2);
    for (long long int k = 0; k < n; k++) t[k + n] = a[k];
    for (long long int k = 0; k < n - 1; k++)
      t[n - k - 1] = min(t[2 * (n - k) - 1], t[2 * (n - k) - 2]);
  }
  void update(long long int index, long long int value) {
    bool on = true;
    index += n - 1;
    t[index] = value;
    index /= 2;
    while (index != 0) {
      t[index] = max(t[index * 2], t[index * 2 + 1]);
      index /= 2;
    }
  }
  long long int query(long long int lt, long long int rt) {
    long long int mn = 1e9 + 5;
    lt += n;
    rt += n;
    while (lt < rt) {
      if (isodd(lt)) mn = min(mn, t[lt++]);
      if (isodd(rt)) mn = min(mn, t[--rt]);
      lt /= 2;
      rt /= 2;
    }
    return mn;
  }
  long long int get(long long int index) { return t[index + (n - 1)]; }
  long long int top() { return t[1]; }
};
vector<vector<long long int> > graph;
bitset<NN> vis;
bitset<NN> cat;
long long int answer;
void dfs(long long int node, long long int cats, long long int mxcats) {
  vis[node] = true;
  if (cats > mxcats) return;
  for (long long int edge = 0; edge < graph[node].size(); edge++) {
    if (!vis[graph[node][edge]]) {
      if (cat[graph[node][edge]])
        dfs(graph[node][edge], cats + 1, mxcats);
      else
        dfs(graph[node][edge], 0, mxcats);
    }
    if (graph[node].size() == 1 && node != 0) answer++;
  }
}
long long int n, m;
long long int ina, inb;
long long int thing;
int main() {
  scanf("%lld", &n);
  ;
  graph.resize(n);
  scanf("%lld", &m);
  ;
  for (long long int k = 0; k < n; k++) {
    scanf("%lld", &thing);
    ;
    cat[k] = thing;
  }
  for (long long int k = 0; k < n - 1; k++) {
    scanf("%lld", &ina);
    ;
    scanf("%lld", &inb);
    ;
    graph[ina - 1].push_back(inb - 1);
    graph[inb - 1].push_back(ina - 1);
  }
  dfs(0, cat[0], m);
  printf("%lld", answer);
  return 0;
}
