#include <bits/stdc++.h>
using namespace std;
int arr[110];
int main() {
  int sum = 0, n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  bool flag = false;
  for (int i = 0; i < n; i++) {
    sum += min(8, arr[i]);
    if (arr[i] > 8) {
      arr[i + 1] += arr[i] - 8;
    }
    if (sum >= k) {
      cout << i + 1 << endl;
      flag = true;
      break;
    }
  }
  if (!flag) {
    cout << -1 << endl;
  }
  return 0;
}
