#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 100;
int a[maxn];
int main() {
  int n, k;
  int sum = 0;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    a[i] = a[i] + a[i - 1];
    if (a[i] > 8)
      sum += 8, a[i] -= 8;
    else
      sum += a[i], a[i] = 0;
    if (sum >= k) {
      cout << i << endl;
      exit(0);
    }
  }
  cout << "-1" << endl;
  return 0;
}
