#include <bits/stdc++.h>   using namespace std;   vector<string> vec_splitter(string s) {     s +=  , ;     vector<string> res;     while (!s.empty()) {       res.push_back(s.substr(0, s.find( , )));       s = s.substr(s.find( , ) + 1);     }     return res;   }   void debug_out(vector<string> __attribute__((unused)) args,                  __attribute__((unused)) int idx,                  __attribute__((unused)) int LINE_NUM) {     cerr <<   n ;   }   template <typename Head, typename... Tail>   void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {     if (idx > 0)       cerr <<  ,  ;     else       cerr <<  Line(  << LINE_NUM <<  )  ;     stringstream ss;     ss << H;     cerr << args[idx] <<   =   << ss.str();     debug_out(args, idx + 1, LINE_NUM, T...);   }   void run() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr), cout.tie(nullptr);   }   const int N = 5e4 + 4, MOD = 1e9 + 7, mod2 = 998244353;   int dp[N][503];   int n, k;   vector<int> adj[N];   long long ans;   void dfs(int u, int p) {     dp[u][0] = 1;     for (auto &v : adj[u]) {       if (v == p) continue;       dfs(v, u);       for (int i = 0; i < k; ++i) {         dp[u][i + 1] += dp[v][i];       }     }     long long sum = 0;     for (auto &v : adj[u]) {       if (v == p) continue;       for (int i = 1; i < k; ++i) {         sum += dp[v][i - 1] * (dp[u][k - i] - dp[v][k - i - 1]);       }     }     ans += dp[u][k] + sum / 2;   }   int main() {     run();     cin >> n >> k;     for (int i = 0; i < (int)(n - 1); ++i) {       int u, v;       cin >> u >> v;       adj[v].push_back(u);       adj[u].push_back(v);     }     dfs(1, -1);     cout << ans;   }   