#include <bits/stdc++.h>
using namespace std;
const int mxN = 1e5 + 100;
vector<int> adj[mxN];
int dp[mxN];
long long h[mxN];
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
int n, m;
cin >> n >> m;
for(int i = 1; i <= n; ++i) cin >> h[i];
for(int i = 1, u, v; i <= n - 1; ++i){
cin >> u >> v;
adj[u].push_back(v);
adj[v].push_back(u);
}
auto dfs = [&](auto &self, int u, int par) -> void {
vector<long long> mn;
for(auto v : adj[u]) {
if(v ^ par){
self(self, v, u);
mn.push_back(h[v]);
dp[u] += dp[v];
}
}
sort(mn.begin(), mn.end());
for(auto x : mn){
if(h[u] + x <= m){
h[u] += x;
}else{
dp[u] += 1;
}
}
};
dfs(dfs, 1, 0);
cout << dp[1] << "\n";
return 0;
}