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