import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.StringTokenizer;

public class capitals_sm_slow_nd {
    ArrayList<Integer>[] es;
    int[] downs;
    int d;

    void solve() throws IOException {
        int n = nextInt();
        d = nextInt();

        es = new ArrayList[n];
        downs = new int[n];
        p = new int[n];
        r = new int[n];
        for (int i = 0; i < es.length; i++) {
            es[i] = new ArrayList<Integer>();

            p[i] = i;
        }
        for (int i = 0; i < n - 1; i++) {
            int x = nextInt() - 1;
            int y = nextInt() - 1;
            es[x].add(y);
            es[y].add(x);

            unionOrError(x, y);
        }
        if (d % 2 != 0) {
            out.println(0);
            return;
        }
        d /= 2;
        long[] sizes = new long[n];
        long[][] dp = new long[n][3];
        long ans = 0;
        for (int c = 0; c < n; c++) {
            for (int i = 0; i < es[c].size(); i++) {
                sizes[i] = count(es[c].get(i), c, d);
                dp[i][0] = (i == 0 ? 0 : dp[i - 1][0]) + sizes[i];
                dp[i][1] = (i == 0 ? 0 : dp[i - 1][1]) + (i == 0 ? 0 : dp[i - 1][0]) * sizes[i];
                dp[i][2] = (i == 0 ? 0 : dp[i - 1][2]) + (i == 0 ? 0 : dp[i - 1][1]) * sizes[i];
            }
            ans += dp[es[c].size() - 1][2];
        }
        out.println(ans);
    }

    long count(int v, int p, int d) {
        if (d == 1) {
            return 1;
        }
        long ans = 0;
        for (int i : es[v]) {
            if (i == p) {
                continue;
            }
            ans += count(i, v, d - 1);
        }
        return ans;
    }


    int[] p, r;

    int get(int x) {
        if (p[x] == x) {
            return x;
        }
        return p[x] = get(p[x]);
    }

    void unionOrError(int a, int b) {
        a = get(a);
        b = get(b);
        if (a == b) {
            throw new AssertionError();
        }
        if (r[a] > r[b]) {
            p[b] = a;
        } else {
            p[a] = b;
            if (r[a] == r[b]) {
                r[b]++;
            }
        }
    }

    int nextInt() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return Integer.parseInt(st.nextToken());
    }

    BufferedReader br;
    PrintWriter out;
    StringTokenizer st;

    void run() throws IOException {
        br = new BufferedReader(new FileReader("capitals.in"));
        out = new PrintWriter("capitals.out");
        solve();
        out.close();
    }

    public static void main(String[] args) throws IOException {
        new capitals_sm_slow_nd().run();
    }
}
