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