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