// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);

    ll a,b,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str;
    vector<ll> v(4);
    char c;
    rep(i,4){
        cin>>c;
        v[i]=atoll(&c);
    }
    if(v[0]+v[1]+v[2]+v[3]==7) {cout<<v[0]<<'+'<<v[1]<<'+'<<v[2]<<'+'<<v[3]<<"=7"<<endl;
    }else if(v[0]+v[1]+v[2]-v[3]==7) {cout<<v[0]<<'+'<<v[1]<<'+'<<v[2]<<'-'<<v[3]<<"=7"<<endl;
    }else if(v[0]+v[1]-v[2]+v[3]==7) {cout<<v[0]<<'+'<<v[1]<<'-'<<v[2]<<'+'<<v[3]<<"=7"<<endl;
    }else if(v[0]+v[1]-v[2]-v[3]==7) {cout<<v[0]<<'+'<<v[1]<<'-'<<v[2]<<'-'<<v[3]<<"=7"<<endl;
    }else if(v[0]-v[1]+v[2]+v[3]==7) {cout<<v[0]<<'-'<<v[1]<<'+'<<v[2]<<'+'<<v[3]<<"=7"<<endl;
    }else if(v[0]-v[1]+v[2]-v[3]==7) {cout<<v[0]<<'-'<<v[1]<<'+'<<v[2]<<'-'<<v[3]<<"=7"<<endl;
    }else if(v[0]-v[1]-v[2]+v[3]==7) {cout<<v[0]<<'-'<<v[1]<<'-'<<v[2]<<'+'<<v[3]<<"=7"<<endl;
    }else if(v[0]-v[1]-v[2]-v[3]==7) {cout<<v[0]<<'-'<<v[1]<<'-'<<v[2]<<'-'<<v[3]<<"=7"<<endl;
    }

    return 0;
}

#include<bits/stdc++.h>

using namespace std;

#define pb push_back
#define fi first
#define se second
typedef pair<int, int> ii;

const int N = 5e3 + 5;
int n, sum;
vector< pair<int, ii> > vec;
priority_queue<int> pq;

int main () {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        int h, p; cin >> h >> p;
        vec.pb( { h + p, { h, p } } );
    }
    sort(vec.begin(), vec.end() );
    for (auto i : vec) {
        if(sum <= i.se.fi) {
            pq.push(i.se.se);
            sum += i.se.se;
        }
        else {
            if(i.se.se < pq.top() ) {
                sum -= pq.top(); pq.pop();
                sum += i.se.se; pq.push(i.se.se);
            }
        }
    }

    cout << pq.size();

    return 0;
}
