#include using namespace std; int main(){ unsigned long N, K; cin >> N >> K; vector> donation(N); for(auto& i : donation)cin >> i.first >> i.second, ++i.second; auto cnt = [&donation, &K](unsigned long T){ unsigned long ret{0}; for(auto i : donation)ret += min(T, i.second) - min(T, i.first); return ret; }; unsigned long l = 0, r = 1000000001; while(l + 1 < r){ auto m = (l + r) / 2; (cnt(m) >= K ? r : l) = m; } cout << l << endl; }