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