#include using namespace std; int main() { int n, k; cin >> n >> k; int gomi; for (int i = (n-1)*2; i--; ) cin >> gomi; cout << (n < k ? -1 : k - 1) << endl; }