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