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