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