#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define inf 2000000000
#define infLL 2000000000000000000
#define MAX5 100005
#define MAX6 1000006
#define MAX7 10000007
#define sf(a) scanf("%d", &a)
#define sfl(a) scanf("%lld", &a)
#define sfs(a) scanf("%s", a)
#define sline(a) scanf("%[^\n]%*c", a);
#define pf(a) printf("%d\n", a)
#define pfl(a) printf("%lld\n", a)
#define pfs(a) printf("%s\n", a)
#define Case(t) printf("Case %d: ", t)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define mod 1000000007
#define Mod 998244353
#define PI acos(-1.0)
#define eps 1e-9
#define mem(a, b) memset(a, b, sizeof(a))
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

const int N = MAX5;

int main()
{
    //#ifndef ONLINE_JUDGE
    //    freopen("in.txt","r",stdin);
    //    freopen("out.txt","w",stdout);
    //#endif

    FASTIO;
    ll a, b, c, d;
    cin>>a>>b>>c>>d;
    if(a==0) cout<<0<<endl;
    else {
        ll mx = a, cnt = 5000000, cc = 0, ans = -1;
        for(int i = 1; i <= cnt; i++) {
            a += b;
            cc += c;
            if(a <= (cc * d)) {
                ans = i;
                break;
            }
            ll dif = a - (cc * d);
            if(dif > mx) {
                break;
            }
            mx = dif;
        }
        cout<<ans<<endl;
    }
    
    return 0;
}

#include "bits/stdc++.h"
using namespace std;

#define ll long long int 
#define pb(a) push_back(a)
#define vll vector<ll>
#define loop(i, n) for(ll i=1;i<=n;i++)
#define loop0(i, n) for(ll i=0;i<n;i++)
#define in(i) scanf("%lld", &i);
#define out(i) printf("%lld", i)
#define pll pair<ll, ll>
#define vpll vector<pair<ll, ll>>
#define mp(i, j) make_pair(i, j)
#define google cout<<"Case #"<<tc-t<<": ";
const ll mod = 1000000007;
const ll big = 2999999999999999999;
const ll small = -2999999999999999999;
void in2(ll& a, ll& b) { in(a); in(b); }
void in3(ll& a, ll& b, ll& c) { in(a); in(b); in(c); }
void swap(ll& a, ll& b) { a = a+b; b = a-b; a = a-b; }
void arrayIn(vll& a, ll& n) { loop0(i, n) in(a[i]); }

ll n, k;
vpll a;

void solve()
{
  in2(n, k);
  a.resize(n);
  loop0(i, n)
    in2(a[i].first, a[i].second);
  sort(a.begin(), a.end());
  ll rem = k;
  ll cv = 0;
  loop0(i, n)
  {
    if(cv + rem < a[i].first)
    {
      cv += rem;
      rem = 0;
      break;
    }
    else
    {
      rem -= (a[i].first-cv);
      rem += a[i].second;
      cv = a[i].first;
    }
  }
  cv += rem;
  cout<<cv<<"\n";
}

int main()
{
    solve();
}
