#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int a[n], i;
  for (i = 0; i <= n - 1; i++) cin >> a[i];
  int carry = 0;
  int score = 0;
  int x = 0;
  for (i = 0; i <= n - 1; i++) {
    a[i] = a[i] + carry;
    int min = (a[i] <= 8 ? a[i] : 8);
    score += min;
    carry = a[i] - min;
    if (score >= k) {
      x++;
      cout << (i + 1) << endl;
      break;
    }
  }
  if (x == 0) cout << (-1) << endl;
}
