#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  if (n == 1 && a[0] > 8)
    cout << "-1" << endl;
  else if (n == 1 && a[0] >= 8)
    cout << "1" << endl;
  else {
    int c = -1;
    for (int i = 0; i < n; i++) {
      if (a[i] <= 8) {
        k = k - a[i];
      } else {
        k = k - 8;
        a[i + 1] += a[i] - 8;
      }
      if (k <= 0) {
        c = i + 1;
        break;
      }
    }
    cout << c << endl;
  }
}
