#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t, n, m, x, a, b, c, j, flag, q, k = 1, len, i, d, l, sum = 0,
                                             extra = 0;
  cin >> n >> k;
  long long ar[n + 5];
  for (i = 0; i < n; i++) cin >> ar[i];
  for (i = 0; i < n; i++) {
    if (ar[i] < 9) {
      a = 8 - ar[i];
      if (a <= extra) {
        sum += 8;
        extra -= a;
      } else {
        sum += ar[i] + extra;
        extra = 0;
      }
    } else {
      sum += 8;
      extra += ar[i] - 8;
    }
    if (sum >= k) {
      cout << i + 1 << endl;
      return 0;
    }
  }
  cout << "-1\n";
  return 0;
}
