#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int ans = 0;
  int stock = 0;
  for (int i = 0; i < n && k > 0; i++) {
    int x;
    cin >> x;
    stock += x;
    int tobegiven = min(stock, 8);
    k -= tobegiven;
    stock -= tobegiven;
    if (k <= 0) {
      cout << i + 1 << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}
