#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, a, b = 0;
  cin >> n >> k;
  int c = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a;
    b += a;
    if (b > 8) {
      k -= 8;
      b -= 8;
    } else {
      k -= b;
      b = 0;
    }
    if (k <= 0) {
      cout << i;
      return 0;
    }
  }
  cout << -1;
  return 0;
}
