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