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