#line 1 "/home/siro53/kyo-pro/compro_library/template/template.cpp"
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
#ifdef DEBUG
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << '(' << p.first << ',' << p.second << ')';
    return os;
}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << '{';
    for(int i = 0; i < (int)v.size(); i++) {
        if(i) { os << ','; }
        os << v[i];
    }
    os << '}';
    return os;
}
void debugg() { cerr << endl; }
template <class T, class... Args>
void debugg(const T &x, const Args &... args) {
    cerr << " " << x;
    debugg(args...);
}
#define debug(...)                                                             \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]: ", debugg(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __Setup;

using ll = long long;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define FOR(i, a, b) for(int i = (a); i < int(b); i++)
#define REP(i, n) FOR(i, 0, n)
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------
#line 2 "d.cpp"

int H, W, A, B;
ll ans;

void dfs(int i, int mask, int a, int b) {
    if(i == H * W) {
        ans++; return;
    }
    if(mask >> i & 1) {
        dfs(i+1, mask, a, b);
        return;
    }
    if(a > 0) {
        if(i % W < W-1 and (mask >> (i+1) & 1) == 0) {
            dfs(i+1, mask | (1 << i) | (1 << (i+1)), a-1, b);
        } 
        if(i / W < H-1 and (mask >> (i+W) & 1) == 0) {
            dfs(i+1, mask | (1 << i) | (1 << (i+W)), a-1, b);
        }
    }
    if(b > 0) {
        dfs(i+1, mask | (1 << i), a, b-1);
    }
}

int main() {
    cin >> H >> W >> A >> B;
    ans = 0;

    dfs(0, 0, A, B);

    cout << ans << endl;
}

#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimization("Ofast")
#pragma GCC optimization("unroll-loops")
#pragma GCC target ("avx2,avx,fma")
typedef long long int ll;
#define int long long int
typedef long double db;
typedef pair <int,int> ii ;
typedef vector < int > vi ;
typedef vector < ii > vii ;
#define rep(i,n)                   for(int i = 0 ; i < n ; i++)
#define repu(i,a,b)                for(int i = a ; i <= b ; i++) 
#define repd(i,b,a)                for(int i = b ; i >= a ; i--)
#define pb push_back
#define fi first
#define se second
#define all(p)                p.begin(),p.end()
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Endl endl
inline ll poww(ll a,ll b){ll r=1LL;while(b>0){if(b&1)r=r*a;b/=2;a=a*a;}return (int)r;}
template <class T>inline void sary(T st, T nd){while(st<nd)cin>>*st++;/*sf("%d", st++);*/}
int mod=998244353;
inline ll mul(ll a, ll b){return ((a%mod)*(b%mod))%mod;}
inline ll add(ll a, ll b){return ((a%mod)+(b%mod))%mod;}
inline ll sub(ll a, ll b){return ((a%mod)-(b%mod)+mod)%mod;}
inline ll divi(ll a, ll b) { return (500000004*(a%mod))%mod; }
const int N= 5002;

void solve() {
  int n; cin>>n;
  vii v(n); 
  rep(i,n) cin>>v[i].fi>>v[i].se;
  int s=0;
  rep(i,n) s+=v[i].fi;
  vi a(n);
  rep(i,n) a[i]=2*v[i].fi+v[i].se;
  sort(all(a),greater<int>());
  int t=-s;
  rep(i,n) {
    t+=a[i];
    if(t>0) {
        cout<<i+1; return;
    }
  }
}   
 
int32_t main() {
  IOS
  int t=1;
  //cin>>t;
  #ifndef ONLINE_JUDGE
    clock_t clk = clock();
    #endif
  while(t--) solve();
  #ifndef ONLINE_JUDGE
  cerr << "\nTime (in ms): " << double(clock() - clk) * 1000.0 / CLOCKS_PER_SEC << '\n';
  #endif
}