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