#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  int t, n, k;
  cin >> n >> k;
  int day = 1, sum = 0;
  int left = 0;
  for (int i = 0; i < n; i++) {
    cin >> t;
    if (t >= 8) {
      sum += 8;
      left += (t - 8);
    } else {
      sum += t;
      if (left >= 8 - t) {
        left -= (8 - t);
        sum += (8 - t);
      } else {
        sum += left;
        left = 0;
      }
    }
    if (sum >= k) {
      cout << day << endl;
      return 0;
    }
    day++;
  }
  cout << -1 << endl;
  return 0;
}
