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