#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int left = 0;
  int total = 0;
  int ans = -1;
  for (int i = 0; i < n; i++) {
    int c;
    cin >> c;
    left += c;
    total += min(8, left);
    left = left - min(8, left);
    if (total >= k) {
      ans = i + 1;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}
