#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5, M = 1e6 + 6, OO = 0x3f3f3f3f;
int n, k;
vector<int> adj[N];
int vis[N], out[N];
int dis[N];
int mxd;
int freq[N];
long long power(long long a, long long b) {
  if (!b) return 1;
  long long t = power(a, b >> 1);
  return t * t * (b & 1 ? a : 1);
}
long long nnodes(long long k) {
  if (k == 1)
    return 4;
  else
    return nnodes(k - 1) + power(3, k);
}
bool BFS() {
  queue<int> q;
  for (int i = 0; i < n; i++) {
    if (out[i] == 1) {
      dis[i] = 0;
      vis[i] = 1;
      q.push(i);
    }
    if (out[i] == 2) return 0;
  }
  while (q.size()) {
    int u = q.front();
    q.pop();
    for (auto v : adj[u]) {
      if (vis[v]) continue;
      if (dis[v] == OO) {
        dis[v] = dis[u] + 1;
        mxd = max(mxd, dis[v]);
      }
      if (dis[v] != dis[u] + 1) {
        return 0;
      }
      out[v]--;
      freq[v]++;
      if (out[v] == 1) {
        if (freq[v] < 3 && dis[v] != k) {
          return 0;
        }
        q.push(v);
        vis[v] = 1;
      }
    }
  }
  return 1;
}
int main() {
  memset(dis, OO, sizeof dis);
  scanf("%d %d", &n, &k);
  long long mx = 0;
  for (int i = 1; i < 1e5; i++) {
    if (nnodes(i) > 1e5) {
      mx = i;
      break;
    }
  }
  if (k > mx || n < nnodes(k)) {
    puts("No");
    return 0;
  }
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    u--, v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
    out[u]++, out[v]++;
  }
  if (!BFS())
    puts("No");
  else {
    if (mxd != k) {
      puts("No");
    } else {
      int cnt = 0;
      for (int i = 0; i < n; i++) {
        if (dis[i] == mxd) cnt++;
      }
      cnt == 1 ? puts("Yes") : puts("No");
    }
  }
  return 0;
}
