#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>
#include <cassert>
#include <random>
#include <chrono>

/* #include <atcoder/all> */
/* using namespace atcoder; */
using namespace std;

void debug_out(){ cout << "\n"; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const ll MOD = 1000000007;
/* const ll MOD = 998244353; */
const ll INF = 1ll<<60;
const double PI = acos(-1);

struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int ans = -1;

  int N, X;
  cin >> N >> X;

  X *= 100;

  int now = 0;
  REP(i, N){
    int v, p;
    cin >> v >> p;
    now += v*p;
    if(now > X){
      cout << i+1 << "\n";
      return 0;
    }
  }

  cout << ans << "\n";


  return 0;
}

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

// string->num
//   stoll(str)
// num->string
//   to_string(i)

int main() {
  ll H, W;
  cin >> H >> W;
  vector<vector<ll>> A(H, vector<ll>(W - 1));
  vector<vector<ll>> B(H - 1, vector<ll>(W));
  for (ll i = 0; i < H; i++) {
    for (ll j = 0; j < W - 1; j++) {
      cin >> A[i][j];
    }
  }
  for (ll i = 0; i < H - 1; i++) {
    for (ll j = 0; j < W; j++) {
      cin >> B[i][j];
    }
  }
  const ll INF = 1e10;
  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<>> q;
  vector<ll> dist(H * W, INF);

  auto push = [&](ll i, ll j, ll cost) {
    ll node = i * W + j;
    if (dist[node] > cost) {
      dist[node] = cost;
      q.emplace(cost, node);
    }
  };
  push(0, 0, 0);
  while (!q.empty()) {
    auto [cost, node] = q.top();
    q.pop();
    if (dist[node] != cost) continue;
    ll i = node / W;
    ll j = node % W;
    if (j + 1 < W) push(i, j + 1, cost + A[i][j]);
    if (j - 1 >= 0) push(i, j - 1, cost + A[i][j - 1]);
    if (i + 1 < H) push(i + 1, j, cost + B[i][j]);
    for (ll k = 0; k < i; k++) {
      push(k, j, cost + (i - k) + 1);
    }
  }
  cout << dist.back() << endl;
  return 0;
}
