#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int day = 0;
  int curr = 0;
  while (day < n and k > 0) {
    curr += a[day];
    if (curr >= 8) {
      k -= 8;
      curr -= 8;
    } else {
      k -= curr;
      curr = 0;
    }
    day++;
  }
  if (k <= 0)
    cout << day << endl;
  else
    cout << -1 << endl;
}
