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