#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REP(i, j, n) for (int i = (j); i < (n); ++i)
#define mp make_pair
using ll = long long;
using ld = long double;
typedef pair<int, int> P;
typedef pair<P, int> COST;
#define repl(i, n) for (ll i = 0; i < (n); ++i)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
using vll = vector<char>;
using GrafPair = vector<vector<P>>;
using Graf = vector<vll>;
#define MAX int(1e9) + 7
#define DOUBLE fixed << setprecision(15)

int main()
{
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n), b(n);
    rep(i,n)cin >> a[i] >> b[i];
    map<ll,ll> money;
    rep(i,n){
        money[a[i]]=0;
    }
    money[0]= k;
    rep(i,n){
        money[a[i]]+=b[i];
    }
    vector<ll> c(n+1);
    c[0]=0;
    rep(i,n)c[i+1]=a[i];
    sort(c.begin(),c.end());
    c.erase(unique(c.begin(),c.end()),c.end());
    ll sum=0;
    ll last=0;
    rep(i,c.size()){
        if(sum>=(c[i]-last)){
            sum-=(c[i]-last);
            sum+=money[c[i]];
            last=c[i];
        }else{
            if(i==0)sum+=k;

            cout << last+sum << endl;
            return 0;
        }
    }
    cout << c[c.size()-1]+sum << endl;

}
#include <bits/stdc++.h>

#define ll long long int

using namespace std;

int main(void)
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N, K, r, m, n;
  cin >> N >> K;
  N--;
  ll sum = N * 3, zero = 0, one = 1, tmp = 0;
  for (r = 0; r <= sum; r++){
    tmp = 0;
    if (r <= N)
      tmp = (r + 1) * (r + 1) - (r + 1) * r / 2;
    else if (r > N && r <= 2 * N)
      tmp = (r - N + 1) * (2 * N - r + 1) + (r - N + 1) * (r - N) / 2
	+ (2 * N - r) * (r + 1) - (2 * N - r) * (r + 1) / 2;
    else
      tmp = (3 * N - r + 1) * (2 * N - r + 1) + (3 * N - r + 1) * (r - N) / 2;
    if (K > tmp)
      K -= tmp;
    else
      break;
  }
  for (m = max(r - 2 * N, zero); m <= min(r, N); m++){
    tmp = (min(N, r - m) - max(r - m - N, zero) + 1);
    if (K > tmp)
      K -= tmp;
    else
      break;
  }
  for (n = max(r - m - N, zero); n <= min(N, r - m); n++){
    if (K > 1)
      K--;
    else
      break;
  }
  cout << m + 1 << ' ' << n + 1 << ' ' << r - m - n + 1 << '\n';
  return 0;
}
