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