#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define rep(i,n) for(ll i=0;i<ll(n);i++)
#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
const double pi = 3.14159265358979;



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

    ll a,b;
    cin >> a >> b;

    cout << (a+b)/2 << " " << (a-b)/2 << endl;
}
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <regex>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using dl = long double;
using P  = pair<int, int>;

int main() {
    int n;
    cin >> n;
    vector<ll> v(n);
    ll sum = 0;
    rep(i, n) {
        ll a, b;
        cin >> a >> b;
        sum += a;
        v[i] = a + a + b;
    }
    sort(v.begin(), v.end());
    int ans = 0;
    while (sum >= 0) {
        sum -= v.back();
        v.pop_back();
        ans++;
    }
    cout << ans << endl;
}