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