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