#include<iostream>
#include<iterator>
#include<algorithm>
#include<climits>
#include<map>
#include<set>
#include<numeric>
#include<string>
#include<sstream>
#define ll long long
using namespace std;



int main()
{
    int h, w;
    cin >> h >> w;
    multiset<int> s;
    for (int i = 0; i < h*w; ++i){
        int x;
        cin >> x;
        s.insert(x);
    }
    int min = *s.begin();
    int sum = 0;
    for (auto i = s.begin(); i != s.end(); ++i){
        sum += *i - min;
    }
    cout << sum;

}
#include <bits/stdc++.h>
//#include <atcoder/all>

typedef long long ll;
using namespace std;
//using namespace atcoder;

#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) for(ll i = 0; i < (ll)n; i++)
#define _reps(i, s, n) for(ll i = (ll)(s); i < (ll)n; i++)
#define REP(...) _overload(__VA_ARGS__, _reps, _rep,)(__VA_ARGS__)
#define all(v) (v).begin(),(v).end()
#define UNIQUE(v) (v).erase( unique( all(v) ), (v).end() );
#define MOD 1000000007

int main(){
	ll n, x;
	cin >> n >> x;
	x *= 100;

	ll v[n], p[n];
	REP(i, n){
		cin >> v[i] >> p[i];
	}

	ll sum = 0;
	REP(i, n){
		sum += v[i] * p[i];
		if( sum > x ){
			cout << i+1 << endl;
			return 0;
		}
	}

	cout << -1 << endl;

	return 0;
}
