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