/*
DISCLAIMER: I don't expect this to AC first submit, but it'd be pretty great if it did...
 -> I'm rusty af
*/
 
 
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> //gp_hash_table
 
#define all(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define sz(a) (int) a.size()
#define bitcount(a) __builtin_popcount(a)
#define bitcountll(a) __builtin_popcountll(a)
 
using namespace std;
// using namespace __gnu_pbds;
 
 
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
 
void solve() {
    const ll oo = 1e18;
    int n; cin >> n;
    vector<pii> a(n);
    for(auto& p : a) cin >> p.first >> p.second;
    sort(all(a), [](const pii& x, const pii& y) {
        int l = x.first - y.second;
        int r = y.first - x.second;
        return l < r;
    });
    a.insert(a.begin(), {-1, -1});
    vector<vector<ll>> dp(n + 1, vector<ll>(n + 1, oo));
    int ans = 0;
    dp[0][0] = 0;
    for(int i = 1; i <= n; ++i) {
        dp[i][0] = 0;
        for(int x = 1; x <= i; ++x) {
            dp[i][x] = dp[i - 1][x];
            if(dp[i - 1][x - 1] <= a[i].first) {
                dp[i][x] = min(dp[i][x], dp[i - 1][x - 1] + a[i].second);
            }
            if(dp[i][x] < oo) {
                ans = max(ans, x);
            }
        }
    }
    cout << ans << endl;
}
 
int main() {
    // freopen("input.in", "r", stdin);
    // freopen("input.out", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
    cout << fixed;
    // int t; cin >> t; while(t--)
    solve();
    cout.flush();
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define LL long long
const int N=2e5+5;

int n;
LL a[90][40];
LL ans;

int main()
{
	cin>>n;
	while(n--)
	{
		string s;
		cin>>s;
		LL y=0;
		int u=s.size();
		for(int i=0;i<s.size();i++)
			if(s[i]=='.') u=i;
		if(u==s.size()) s+=".";
		for(int i=s.size()-u;i<=9;i++) s+="0";
		for(int i=0;i<s.size();i++)
			if(s[i]!='.') y=y*10+s[i]-'0';
		int z1=0,z2=0;
		while(y%2==0) y/=2,z1++;
		while(y%5==0) y/=5,z2++;
		a[z1+36][z2+11]++;
	}
	for(int i=0;i<90;i++)
	for(int j=0;j<40;j++)
	for(int k=90-i;k<90;k++)
	for(int l=40-j;l<40;l++)
		ans+=a[i][j]*a[k][l];
	for(int i=45;i<90;i++)
	for(int j=20;j<40;j++)
		ans-=a[i][j];
	cout<<ans/2<<'\n';
	
	return 0;
}