#include <bits/stdc++.h>
using namespace std;
int A[107];
int main() {
  int i, j, k, l, m, n, x, y, z, a, b, r;
  scanf("%d", &n);
  scanf("%d", &k);
  for (i = 1; i <= n; i++) scanf("%d", &A[i]);
  for (a = 0, b = 0, i = 1; i <= n; i++) {
    a += A[i];
    x = min(8, a);
    b += x;
    a -= x;
    if (b >= k) {
      printf("%d\n", i);
      return 0;
    }
  }
  printf("-1\n");
  return 0;
}
