#include <bits/stdc++.h>
using namespace std;
int n, k, cur = 0;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> k;
  for (int i = 1, x; i <= n; i++) {
    cin >> x;
    if (x > 8) {
      while (cur < 8) {
        x--;
        cur++;
      }
      if (cur >= 8) {
        k -= 8;
        cur -= 8;
        cur += x;
      }
    } else if (x == 8) {
      while (cur < 8) {
        x--;
        cur++;
      }
      if (cur >= 8) {
        k -= 8;
        cur -= 8;
        cur += x;
      }
    } else {
      if (cur + x >= 8) {
        k -= 8;
        if (cur >= 8) {
          cur -= 8;
          cur += x;
        } else {
          cur = cur + x - 8;
        }
      } else {
        k -= cur + x;
        cur = 0;
      }
    }
    if (k <= 0) return cout << i, 0;
  }
  cout << -1;
}
