#include using namespace std; typedef long long ll; int main(){ int n;ll k; cin>>n>>k; ll a[100001], b[100001]; for(int i=0; i>a[i]>>b[i]; } ll x1=0, x2=1e9+7; while(x1!=x2){ ll x=(x1+x2)/2; ll c=0; for(int i=0; i=b[i]){ c+=(b[i]-a[i]+1); }else{ c+=(x-a[i]+1); } } if(c