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