#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int v[N];
int main(void) {
  int n, k;
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; i++) scanf("%d", v + i);
  int arya = 0;
  int k2 = k;
  for (int i = 0; i <= n - 1; i++) {
    arya += v[i];
    k -= min(8, arya);
    arya -= min(8, arya);
    if (k <= 0) {
      printf("%d\n", i + 1);
      return 0;
    }
  }
  printf("-1\n");
  return 0;
}
