#include <bits/stdc++.h>
using namespace std;
const int inf = 2147483647;
const long long Inf = 9223372036854775807ll;
const string file = "";
int n, m, g[100005], g2[100005], c[100005], d[100005];
vector<int> v[100005];
queue<int> q;
bool ok[100005];
void dfs(int x, int pred = 0) {
  ok[x] = 0;
  d[x] = d[pred] + 1;
  for (auto y : v[x])
    if (ok[y]) dfs(y, x);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> m;
  for (int i = 1; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
    ++g[x];
    ++g[y];
  }
  for (int i = 1; i <= n; ++i) {
    if (g[i] == 1) q.push(i);
    g2[i] = g[i];
  }
  int last;
  while (!q.empty()) {
    int x = q.front();
    last = x;
    q.pop();
    ok[x] = 1;
    for (auto y : v[x])
      if (!ok[y]) {
        --g[y];
        ++c[y];
        if (g[y] == 1) q.push(y);
      }
  }
  dfs(last);
  for (int i = 1; i <= n; ++i)
    if (g2[i] != 1 && c[i] < 3) {
      cout << "NO";
      return 0;
    } else if (g2[i] == 1 && d[i] - 1 != m) {
      cout << "NO";
      return 0;
    }
  cout << "YES";
  return 0;
}
