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