#include using namespace std; typedef long long ll; typedef pair l_l; #define EPS (1e-7) #define INF (1e9) #define PI (acos(-1)) //const ll mod = 1000000007; int main() { //cout.precision(10); cin.tie(0); ios::sync_with_stdio(false); int N, K; cin >> N >> K; K++; int A[100500]; int B[100500]; for(int i = 1; i <= N; i++) cin >> A[i] >> B[i]; int ok = INF; int ng = 0; while(ok - ng > 1) { int mid = (ok + ng) / 2; int now = 0; for(int i = 1; i <= N; i++) { int NEW = min(B[i], mid) - A[i] + 1; now += max(0, NEW); if(now >= K) break; } if(now >= K) ok = mid; else ng = mid; } cout << ok << endl; return 0; }