#include <iostream>
#include <vector>
using namespace std;
const int maxn = 52013;
struct Edge{
int to;
};
vector<Edge*> edges[maxn];
int n,d,ans;
void Add(int u,int v){
Edge* e = new Edge;
e->to = v;
edges[u].push_back(e);
}
void DFS(int now,int fa,int deep){
if(deep <= d) ans++;
for(Edge* p : edges[now]){
if(p->to != fa){
DFS(p->to,now,deep+1);
}
}
}
int main(){
cin>>n>>d;
for(int i = 1;i <= n-1;i++){
int u,v;
cin>>u>>v;
Add(u,v);Add(v,u);
}
DFS(1,0,0);
cout<<ans-1<<endl;
return 0;
}
这段代码在本地和在线IDE都能跑,提交就RE,搞不懂。