#include using namespace std; #define rep(i,n) for(int i = 0;i<((int)(n));i++) #define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++) #define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--) #define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--) typedef long long ll; /* */ ll n,k,sum=0,tmp=0,before=0,ans; map m; void init(){ cin>>n>>k; rep(i,n){ ll a,b; cin>>a>>b; m[a]++; m[b+1]--; } } int main(void){ init(); for(auto itr = m.begin(); itr != m.end(); ++itr) { if(sum+tmp*(itr->first-before)>=k){ ans=before+(k-sum)/tmp; break; } sum += tmp*(itr->first-before); tmp += itr->second; before = itr->first; // cout<second<