#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dbg(...) 47
#endif
constexpr int N = 1e5;
constexpr int inf = 1e9;
int a[N];
vector<int> g[N];
int n, k;
array<int, 2> dp[N];
void dfs(int u, int p) {
bool leaf = true;
for (auto v : g[u]) {
if (v == p) continue;
leaf = false;
dfs(v, u);
}
if (leaf) {
dp[u] = {0, a[u]};
return;
}
ranges::sort(g[u], [&](int x, int y) {
return dp[x][1] > dp[y][1];
});
int s = a[u];
for (auto v : g[u]) {
if (v == p) continue;
dp[u][0] += dp[v][0];
s += dp[v][1];
if (s > k) {
s = a[v];
dp[u][0]++;
}
}
dp[u][1] = s;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> k;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
for (int i = 1; i < n; i++) {
int u, v;
cin >> u >> v;
u--; v--;
g[u].push_back(v);
g[v].push_back(u);
}
dfs(0, -1);
cout << dp[0][0] << '\n';
return 0;
}