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