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