#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
using P = pair<int,int>;

int main() {
	int H, W, min, ans = 0;
	cin >> H >> W;
	vector <int> vec(H * W);
	rep(i, H * W) cin >> vec.at(i);
	sort(vec.begin(), vec.end());
	min = vec.at(0);
	rep(i, H * W) ans += (vec.at(i) - min);
	cout << ans << endl;
  return 0;
}
#include <bits/stdc++.h>

using namespace std;

#define int long long
#define double long double

#define FOR(i,l,r,d) for(int i=(l);i<=(r);i+=(d))

#define vi vector<int>
#define pii pair<int,int>

#define F first
#define S second

#define pb push_back
#define eb emplace_back
#define mkp make_pair

const int INF=2147483647;
const int MOD=1000000007;
const int mod=998244353;

int n;
int lim;
int v[1001],p[1001];
int sum;
int ptr;

signed main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>lim;

    lim*=100;

    FOR(i,0,n-1,1){
        cin>>v[i]>>p[i];
    }
    v[n] = INF;
    p[n] = INF;

    ptr=0;
    while(sum<=lim){
        sum += v[ptr]*p[ptr];
        ptr++;
    }

    if(ptr==n+1) cout<<-1<<endl;
    else cout<<ptr<<endl;

    return 0;

}
