#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int i, flag = 0, pum = 0, count = 0;
  for (i = 0; i < n; i++) {
    int x;
    cin >> x;
    pum += x;
    k -= min(8, pum);
    pum -= min(8, pum);
    if (k <= 0 && flag == 0) {
      count = i + 1;
      flag = 1;
    }
  }
  if (k > 0)
    cout << -1;
  else
    cout << count;
  return 0;
}
