#pragma GCC optimize ("Ofast") #include using namespace std; inline void rd(int &x){ int k; int m=0; x=0; for(;;){ k = getchar_unlocked(); if(k=='-'){ m=1; break; } if('0'<=k&&k<='9'){ x=k-'0'; break; } } for(;;){ k = getchar_unlocked(); if(k<'0'||k>'9'){ break; } x=x*10+k-'0'; } if(m){ x=-x; } } inline void wt_L(char a){ putchar_unlocked(a); } inline void wt_L(int x){ int s=0; int m=0; char f[10]; if(x<0){ m=1; x=-x; } while(x){ f[s++]=x%10; x/=10; } if(!s){ f[s++]=0; } if(m){ putchar_unlocked('-'); } while(s--){ putchar_unlocked(f[s]+'0'); } } struct graph{ int N; int *es; int **edge; } ; int N; int K; int A[100000]; int B[100000]; int d[100000]; graph g; int main(){ long long res = 0; rd(N); rd(K); { int Lj4PdHRW; for(Lj4PdHRW=(0);Lj4PdHRW<(N-1);Lj4PdHRW++){ rd(A[Lj4PdHRW]);A[Lj4PdHRW] += (-1); rd(B[Lj4PdHRW]);B[Lj4PdHRW] += (-1); } } if(K > N){ wt_L(-1); wt_L('\n'); return 0; } wt_L(K-1); wt_L('\n'); return 0; } // cLay varsion 20200217-1 // --- original code --- // int N, K, A[1d5], B[1d5]; // int d[1d5]; // graph g; // { // ll res = 0; // rd(N,K,(A--,B--)(N-1)); // if(K > N) wt(-1), return 0; // wt(K-1); // }