#include <bits/stdc++.h>
using namespace std;
int n, k, a[100005];
int main() {
  scanf("%d %d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  int sv = 0, tp = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i] > 8) {
      sv += a[i] - 8;
    }
    tp += min(a[i], 8);
    if (a[i] < 8) {
      int dc = min(sv, 8 - a[i]);
      sv -= dc;
      tp += dc;
    }
    if (tp >= k) {
      printf("%d", i);
      return 0;
    }
  }
  printf("-1");
}
