#include <bits/stdc++.h>
using namespace std;
long long i, j, n, m, x, y, p, t, k, d, a[100009];
int main() {
  cin >> n >> k;
  for (i = 1; i <= n; i++) {
    cin >> x;
    if (x >= 8) {
      d += x - 8;
      t += 8;
    } else {
      t += x;
      m = 8 - x;
      if (m <= d)
        t += m, d -= m;
      else
        t += d, d = 0;
    }
    if (t >= k) {
      cout << i;
      return 0;
    }
  }
  cout << -1;
}
