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