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