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