#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int d = 0, tot = 0, c;
  bool flag = false;
  for (int i = 0; i < n; i++) {
    cin >> c;
    tot = tot + c;
    if (tot >= 8 && flag == false) {
      k = k - 8;
      tot = tot - 8;
      d++;
      if (k <= 0) flag = true;
    } else if (tot < 8 && flag == false) {
      k = k - tot;
      tot = 0;
      d++;
      if (k <= 0) flag = true;
    }
  }
  if (flag == true) {
    cout << d << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}
