#include #define int long long using namespace std; using Graph = vector>; signed main(){ int N, K; cin >> N >> K; Graph G(N); for( int i = 0; i < N-1; i++ ){ int A, B; cin >> A >> B; A--; B--; G.at(A).push_back(B); G.at(B).push_back(A); } if( N < K ) cout << -1 << endl; else cout << K-1 << endl; }