#include using namespace std; typedef long long ll; #define reps(i,a,b) for(int i=(a);i<(b);++i) #define rep(i,n) reps(i,0,n) #define all(x) (x).begin(),(x).end() #define INF (1000000000) #define MOD (1000000007) #define PI (acos(-1)) ll N,K; ll A[100010],B[100010]; bool isOK(ll x){//x円以下のコインがk枚以上存在するか ll cnt=0; rep(i,N){ cnt += (min(B[i],x)-A[i])+1; if(cnt >= K)return true; } return false; } int main(){ cin >> N >> K; rep(i,N){ cin >> A[i] >> B[i]; } ll ok = 1e9+7, ng = 0; while(abs(ok-ng)>1){ ll mid = (ok+ng)/2; if(isOK(mid)){ ok = mid; }else{ ng = mid; } } cout << ok << endl; }