#include using namespace std; typedef long long int ll; typedef pair P; #define repi(i,a,b) for(ll i=a;i=0;i--) #define MOD 1000000007 //debug #define debug(arr) cerr<<#arr<<"(l"<<__LINE__<<") : ";for(auto x:arr)cerr<> N >> K; ll a, b; rep(i, N-1) cin >> a >> b; ll ans = (N >= K) ? (K - 1) : -1; cout << ans << endl; return 0; }