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