#include <bits/stdc++.h>   using namespace std;   const int INF = 1 << 29;   const double EPS = 1e-10;   vector<int> G[50010];   vector<int> chil[50010];   int cnt[50010][510];   void dfs(int pos, int par) {     for (int i = 0; i < (int)G[pos].size(); i++) {       if (G[pos][i] != par) {         chil[pos].push_back(G[pos][i]);         dfs(G[pos][i], pos);       }     }   }   void init(int n) {     memset(cnt, 0, sizeof(cnt));     dfs(0, -1);   }   void calc(int v, int k, long long &sum) {     for (int i = 0; i < (int)chil[v].size(); i++) {       int c = chil[v][i];       calc(c, k, sum);       for (int j = 0; j < k; j++) {         sum += (long long)cnt[c][j] * cnt[v][k - j - 1];       }       for (int j = 0; j < k; j++) {         cnt[v][j + 1] += cnt[c][j];       }     }     cnt[v][0] = 1;     sum += (long long)cnt[v][0] * cnt[v][k];   }   int main() {     int n, k, a, b;     cin >> n >> k;     for (int i = 0; i < n - 1; i++) {       cin >> a >> b;       a--, b--;       G[a].push_back(b);       G[b].push_back(a);     }     init(n);     long long res = 0;     calc(0, k, res);     cout << res << endl;     return 0;   }   