#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef vector<int> vii;
typedef vector<pii> vpii;
typedef unordered_map<int,int> umap;
typedef long double ld;
#define fi first
#define se second
#define pb push_back
#define mp make_pairNa
#define popcount __builtin_popcount
#define case cout<<"Case "<<z-t<<": ";
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,m,i,j,k;
    cin>>n>>m;
    pair<ll,ll> fnd[n];
    for(i=0;i<n;i++) cin>>fnd[i].fi>>fnd[i].se;
    sort(fnd,fnd+n);
    ll ans=m;
    for(i=0;i<n;i++){
        if(ans>=fnd[i].fi) ans+=fnd[i].se;
        else break;
    }
    cout<<ans<<endl;
}

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i,n) for(int i=0;i<(n);i++)
#define mod (1000000007)

int main()
{
	int N,W;
	cin >> N >> W;
	cout << (N / W) << endl;
}