#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int N, M;
  cin >> N >> M;
  long long int c = 0;
  long long int sum = M;
  long long int day = 0;
  bool flag = false;
  for (long long int i = 0; i < N; i++) {
    long long int temp;
    cin >> temp;
    c += temp;
    if (sum > 0) {
      sum -= (c >= 8 ? 8 : c);
      c -= (c >= 8 ? 8 : c);
      day++;
    } else {
      flag = true;
      break;
    }
  }
  if (sum <= 0) flag = true;
  if (flag)
    cout << day << endl;
  else
    cout << -1 << endl;
  return 0;
}
