#include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int N, K; cin >> N >> K; for (int i = 0; i < N - 1; i++) { int a, b; cin >> a >> b; } if (N >= K) { cout << K - 1 << '\n'; } else { cout << -1 << '\n'; } return 0; }