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