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