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