#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, k, flag = 0, ans;
  cin >> n >> k;
  int choc[n];
  for (i = 0; i < n; i++) {
    cin >> choc[i];
  }
  int bag = 0, given = 0;
  for (i = 0; i < n; i++) {
    bag += choc[i];
    if (bag >= 8) {
      bag -= 8;
      given += 8;
    } else {
      given += bag;
      bag = 0;
    }
    if (given >= k) {
      ans = i + 1;
      flag = 1;
      break;
    }
  }
  if (!flag) {
    cout << -1 << endl;
  } else
    cout << ans << endl;
  return 0;
}
