#include <bits/stdc++.h>
using namespace std;
int n, k, x, y, sum, s;
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> k;
  for (int i = 1; i <= n; ++i) {
    cin >> x;
    sum += x;
    if (sum >= 8)
      y = 8;
    else
      y = sum;
    sum -= y;
    s += y;
    if (s >= k) {
      cout << i;
      return 0;
    }
  }
  cout << -1;
  return 0;
}
