#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 1020;   int n, m, d, tmp;   int h[maxn], dis1[maxn], dis2[maxn];   bool mark[maxn], isaffected[maxn];   vector<int> adj[maxn];   pair<int, int> temp;   void dfsa(int v) {     for (int i = 0; i < adj[v].size(); i++) {       int u = adj[v][i];       if (!mark[u]) {         mark[u] = true;         h[u] = h[v] + 1;         dfsa(u);         if (h[u] > tmp && isaffected[u]) {           tmp = h[u];           temp.first = u;         }       }     }   }   void dfsb(int v) {     for (int i = 0; i < adj[v].size(); i++) {       int u = adj[v][i];       if (!mark[u]) {         mark[u] = true;         h[u] = h[v] + 1;         dfsb(u);         if (h[u] > tmp && isaffected[u]) {           tmp = h[u];           temp.second = u;         }       }     }   }   void dfs1(int v) {     for (int i = 0; i < adj[v].size(); i++) {       int u = adj[v][i];       if (!mark[u]) {         mark[u] = true;         dis1[u] = dis1[v] + 1;         dfs1(u);       }     }   }   void dfs2(int v) {     for (int i = 0; i < adj[v].size(); i++) {       int u = adj[v][i];       if (!mark[u]) {         mark[u] = true;         dis2[u] = dis2[v] + 1;         dfs2(u);       }     }   }   int main() {     cin >> n >> m >> d;     for (int i = 1; i <= m; i++) {       int x;       cin >> x;       isaffected[x] = true;     }     for (int i = 1; i < n; i++) {       int a, b;       cin >> a >> b;       adj[a].push_back(b);       adj[b].push_back(a);     }     mark[1] = true;     dfsa(1);     for (int i = 1; i <= n; i++) {       h[i] = 0;       mark[i] = false;     }     h[temp.first] = 0;     tmp = 0;     mark[temp.first] = true;     dfsb(temp.first);     for (int i = 1; i <= n; i++) {       mark[i] = false;     }     dis1[temp.first] = 0;     mark[temp.first] = true;     dfs1(temp.first);     for (int i = 1; i <= n; i++) {       mark[i] = false;     }     dis2[temp.second] = 0;     mark[temp.second] = true;     dfs2(temp.second);     for (int i = 1; i <= n; i++) {       mark[i] = false;     }     int ans = 0;     for (int i = 1; i <= n; i++) {       if (max(dis1[i], dis2[i]) <= d) {         ans++;       }     }     cout << ans;   }   