#include #include #include #include #include #include #include #include #include #include #include #include #include using ll = long long; using namespace std; constexpr int MOD = 1e9 + 7; constexpr ll MOD_LL = ll(1e9) + 7; int main(void) { int n, k; cin >> n >> k; vector< vector > t(n); for(int i = 0; i < n - 1; ++i) { int a, b; cin >> a >> b; a--; b--; t[a].push_back(b); t[b].push_back(a); } if( n < k ) { cout << -1 << endl; } else { cout << k - 1 << endl; } return 0; }