#include <bits/stdc++.h>
using namespace std;
const int N = 50001;
const int MOD = 1000000007;
const int INF = 0x3fffffff;
typedef struct Edge {
  int u, v, next;
} Edge;
Edge es[N + N];
int head[N];
int ecnt;
const int K = 501;
long long dp[N][K];
int n, k;
long long ans;
void addEdge(int u, int v) {
  es[ecnt].u = u;
  es[ecnt].v = v;
  es[ecnt].next = head[u];
  head[u] = ecnt++;
  es[ecnt].u = v;
  es[ecnt].v = u;
  es[ecnt].next = head[v];
  head[v] = ecnt++;
}
void dfs(int u, int fa) {
  dp[u][0] = 1;
  for (int i = head[u]; i != -1; i = es[i].next) {
    if (es[i].v == fa) continue;
    int v = es[i].v;
    dfs(v, u);
    for (int j = 0; j < k; ++j) ans += dp[u][j] * dp[v][k - j - 1];
    for (int j = 1; j <= k; ++j) {
      dp[u][j] += dp[v][j - 1];
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  scanf("%d%d", &n, &k);
  int u, v;
  memset(head, -1, sizeof(head));
  for (int i = 1; i < n; ++i) {
    scanf("%d%d", &u, &v);
    addEdge(u, v);
  }
  dfs(1, 0);
  printf("%d\n", ans);
  return 0;
}
