#include typedef long long ll; typedef long double ld; using namespace std; int main(){ int N, K; cin >> N >> K; vector> tree(N); for(int i=0; i> a >> b; a--; b--; tree[a].push_back(b); tree[b].push_back(a); } if(K > N){ cout << -1 << endl; return 0; }else{ cout << K-1 << endl; } }