#include <bits/stdc++.h>
int main() {
  int n, k, i, st = 0, cnt = 0;
  scanf("%d %d", &n, &k);
  int a[n];
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  for (i = 0; i < n && k > 0; i++) {
    if (a[i] <= 8) {
      k -= a[i], cnt++;
      if (st > 0 && st <= (8 - a[i]))
        k -= st, st = 0;
      else if (st > 0 && st > (8 - a[i]))
        k -= (8 - a[i]), st -= (8 - a[i]);
    } else {
      k -= 8;
      st += (a[i] - 8);
      cnt++;
    }
  }
  if (k > 0)
    printf("-1");
  else
    printf("%d", cnt);
}
