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