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