#include <bits/stdc++.h>
using namespace std;
int main() {
  int ck, n, k, T = 0;
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &ck);
    T = T + ck;
    if (T > 8) {
      T = T - 8;
      k = k - 8;
    } else {
      k = k - T;
      T = 0;
    }
    if (k <= 0) {
      cout << i << endl;
      break;
    }
  }
  if (k > 0) cout << "-1" << endl;
  return 0;
}
