#include using namespace std; int main() { int n; long long k; cin >> n >> k; map m; for (int i = 0; i < n; i++) { long long a, b; cin >> a >> b; m[a]++; m[b+1]--; } long long cur = 0; long long prev = 0; for (auto it: m) { if (k - (it.first - prev) * cur <= 0) { cout << prev + (k + cur-1) / cur - 1 << endl; return 0; } k -= (it.first - prev) * cur; prev = it.first; cur += it.second; } return 0; }