#include <bits/stdc++.h>   const int Max_N(1000005);   int N, D;   int first[Max_N], ecnt(1), Next[Max_N * 2], To[Max_N * 2];   int degree[Max_N];   std::tuple<int, int> dfs(const int v, const int p = 0) {     if (To[first[v]] == p && Next[first[v]] == 0) return std::make_tuple(0, 0);     int res(0), max(0), min(D + 1);     for (int e(first[v]); e; e = Next[e])       if (To[e] != p) {         int len(1);         auto tmp(dfs(To[e], v));         res += std::get<0>(tmp), len += std::get<1>(tmp);         if (len >= 0) {           if (len == D)             ++res;           else if (len * 2 > D)             min = std::min(min, len), ++res;           else             max = std::max(max, len);         }       }     if (max == 0 && min == D + 1) return std::make_tuple(res, -1);     return std::make_tuple(res - (max + min <= D), max + min <= D ? min : max);   }   int main(int argc, char **argv) {     scanf( %d %d , &N, &D);     int r;     for (int i(1), v, w; i != N; ++i) {       scanf( %d %d , &v, &w);       Next[ecnt] = first[v], To[ecnt] = w, first[v] = ecnt++;       Next[ecnt] = first[w], To[ecnt] = v, first[w] = ecnt++;       ++degree[v], ++degree[w];       if (degree[v] > 1) r = v;       if (degree[w] > 1) r = w;     }     auto res(dfs(r));     printf( %d , std::get<0>(res) + (std::get<1>(res) != -1));     return 0;   }   