#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <queue>
#include <memory.h>
#include <stack>
#define mp make_pair
#define pb push_back                     
#define setval(a,v) memset(a,v,sizeof(a))

#if ( _WIN32 || __WIN32__ )
    #define LLD "%I64d"
#else
    #define LLD "%lld"
#endif

using namespace std;

typedef long long ll;
typedef long double ld;

const int MAXN = 110000;

struct item{
	vector<vector<int> > v;
	int total;
	vector<int> add;
	void swap(item& r){
		v.swap(r.v);
		add.swap(r.add);
		::swap(total,r.total);
	}
};

vector<int> g[MAXN];
ll sum[MAXN];
ll sumsqr[MAXN];
ll sumcube[MAXN];
int up[MAXN];
int h[MAXN];
ll ans;
item res[MAXN];
int n,d;


void merge(item& a,item& b){
	if (a.total < b.total)
		a.swap(b);

	if (a.v.size() < b.v.size()){
	    int dlt = b.v.size() - a.v.size();
		a.v.resize(b.v.size());
		a.add.resize(b.v.size());
		for (int i = (int)a.v.size()-1; i >= dlt; i--){
			a.v[i].swap(a.v[i-dlt]);
			::swap(a.add[i],a.add[i-dlt]);
		}

	}

	for (int i = 0; i < (int)b.v.size() && i <= d; i++){
		int id2 = (int)b.v.size() - i - 1;
		int id1 = (int)a.v.size() - (d-i) - 1;
		if (0 <= id1 && id1 < (int)a.v.size()){
    		if (id1+1 != (int)a.v.size()) a.add[id1] += b.v[id2].size();
    		if (id2+1 != (int)b.v.size()) b.add[id2] += a.v[id1].size();
		}
	}
                               

	for (int i = 0; i < (int)b.v.size(); i++){
		int id2 = (int)b.v.size() - i - 1;
		int id1 = (int)a.v.size() - i - 1;
		assert(0 <= id1 && id1 < (int)a.v.size());
		for (int j = 0; j < (int)b.v[id2].size(); j++){
			int t = b.v[id2][j];
			up[t] += b.add[id2];
			up[t] -= a.add[id1];
			a.v[id1].pb(t);
			a.total++;
		}
	} 
}

void dfs(int v,int p,int h){
	res[v].v.pb(vector<int>());
	res[v].v[0].pb(v);
	res[v].total = 1;
	res[v].add.pb(0);
	::h[v] = h;

	for (int i = 0; i < (int)g[v].size(); i++){
		int to = g[v][i];
		if (to == p) continue;
		dfs(to,v,h+1);                                                    
		int x = ((int)res[to].v.size() >= d? res[to].v[res[to].v.size()-d].size() : 0);
	//	cerr << v <<" "<<x<<endl;
		sum[v] += x;
		sumsqr[v] += x*1LL*x;
		sumcube[v] += x*1LL*x*1LL*x;

		res[to].v.pb(vector<int>());
		res[to].add.pb(0);

		merge(res[v],res[to]);
	}
}


int main(){
  freopen("capitals.in","r",stdin);
  freopen("capitals.out","w",stdout);

  scanf("%d %d",&n,&d);
  if (d % 2 != 0){
  	cout << 0 << endl;
  	return 0;
  }
  d /= 2;
  for (int i = 0; i < n-1; i++){
  	int a,b;
  	scanf("%d %d",&a,&b);
  	--a,--b;
  	g[a].pb(b);
  	g[b].pb(a);
  }

  dfs(0,-1,0);

  for (int i = 0; i < n; i++){
     assert((int)res[0].add.size() > h[i]);
  	 up[i] += res[0].add[res[0].add.size() - h[i] - 1];
  }

  //cerr << endl << endl;

  for (int i = 0; i < n; i++){
    //cerr << i <<" "<<up[i] << endl;
  	sum[i] += up[i];
  	sumsqr[i] += (up[i] * 1LL * up[i]);
  	sumcube[i] += (up[i] * 1LL * up[i] * 1LL * up[i]);
  	assert((sum[i] * sum[i] * sum[i] - 3 * sum[i] * sumsqr[i] +2* sumcube[i])%6 == 0);
  	ans += (sum[i] * sum[i] * sum[i] - 3 * sum[i] * sumsqr[i] +2* sumcube[i])/6;
  }

  cout << ans << endl;

      
  return 0;
}
