#include <bits/stdc++.h>
using namespace std;

int main() {
  long long N,L;
  cin >> N >> L;
  
  vector<long long> A(N+2),B(N+2);
  
  for (int i=0; i<N; i++) {
    cin >> A[i+1];
  }
  
  for (int i=0; i<N; i++) {
    cin >> B[i+1];
  }
  
  A[0] = 0;
  B[0] = 0;
  A[N+1] = L+1;
  B[N+1] = L+1;
  
  long long ans = 0;
  
  long long NG,OK,md;
  
  for (int i=1; i<N+1; i++) {
    if (B[i] == A[i]) {
      continue;
    }
    if (A[i] < B[i] && A[i+1] > B[i+1]) {
      cout << -1 << endl;
      return 0;
    }
    if ((A[i] < B[i] && B[i] == B[i+1]-1 ) || (A[i] > B[i] && B[i] == B[i-1]+1 )) {
      ans++;
      continue;
    }
    if (B[i] > A[i]) {
      NG = i;
      OK = N+1;
      md = (NG+OK) / 2;
      while (OK - NG > 1) {
        md = (NG+OK) / 2;
        if (A[md] >= B[i] + (md-i)) {
          OK = md;
        }
        else {
          NG = md;
        }
      }
      if (A[OK] != B[i] + (OK-i)) {
        cout << -1 << endl;
        return 0;
      }
      else {
        ans += (OK-i);
      }
    }
    else {
      NG = i;
      OK = 0;
      md = (NG+OK) / 2;
      while (NG - OK > 1) {
        md = (NG+OK) / 2;
        if (A[md] <= B[i] + (md-i)) {
          OK = md;
        }
        else {
          NG = md;
        }
      }
      if (A[OK] != B[i] + (OK-i)) {
        cout << -1 << endl;
        return 0;
      }
      else {
        ans += (i-OK);
      }
    }
  }
  
  cout << ans << endl;
  
  return 0;
}
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main(){
    int n, x;
    int v, p;
    cin >> n >> x;
    int cnt = 0;
    int sum = 0;
    bool flag = true;
    rep(i, n){
        cin >> v >> p;
        sum += v*p;
        if(sum > 100*x && flag){
            cnt = i+1;
            flag = false;
        }
    }
    if(flag) cout << -1 << endl;
    else cout << cnt << endl;
    return 0;
}