#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  if (n * 8 < k) {
    cout << -1 << endl;
    return 0;
  }
  int stash = 0;
  for (int i = 0; i < n; i++) {
    int curr;
    cin >> curr;
    stash += curr;
    curr = (stash > 8) ? 8 : stash;
    stash -= curr;
    k -= curr;
    if (k <= 0) {
      cout << i + 1 << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}
