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