#include <bits/stdc++.h>
using namespace std;
int main() {
  int days, candies, total = 0, sobrante = 0, candiesDay, numberDay = -1;
  cin >> days >> candies;
  for (int i = 0; i < days; i++) {
    cin >> candiesDay;
    if (total < candies) {
      sobrante += candiesDay;
      if (sobrante >= 8) {
        total += 8;
        sobrante -= 8;
      } else {
        total += sobrante;
        sobrante = 0;
      }
      if (total >= candies) {
        numberDay = i + 1;
        break;
      }
    }
  }
  if (total >= candies && numberDay == -1) {
    numberDay = days;
  }
  cout << numberDay << endl;
  return 0;
}
