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