#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll inf = 3e18;
void solve() {
int n, k;
cin >> n >> k;
vector<vector<int>>g(n + 1);
vector<ll> h(n + 1), rem(n + 1), cnt(n + 1);
for(int i = 1;i<=n;i++){
cin >> h[i];
}
for(int i = 2;i<=n;i++){
int a,b;
cin >> a >> b;
g[a].push_back(b);
g[b].push_back(a);
}
auto dfs = [&](auto self, int x, int pr) -> void {
rem[x] = h[x];
vector<ll>v;
for(auto to : g[x]){
if(to == pr)continue;
self(self, to, x);
v.push_back(rem[to]);
cnt[x] += cnt[to];
rem[x] += rem[to];
}
sort(v.begin(), v.end());
while(!v.empty()){
if(rem[x] > k){
rem[x] -= v.back();
v.pop_back();
cnt[x] += 1;
}
else break;
}
};
dfs(dfs, 1, -1);
cout << cnt[1] << "\n";
}
/*
10 10
3 4 2 3 7 1 4 1 5 2
1 2
2 4
5 2
6 3
3 1
6 7
9 7
8 6
8 10
//
5 5
1 2 3 4 5
1 2
2 3
3 4
4 5
//
6 9
5 4 1 3 3 3
3 1
3 5
4 3
4 2
2 6
*/
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr); cout.tie(nullptr);
int tt = 1;
while (tt--) solve();
}