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