#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, i, k, s = 0, carry = 0;
  cin >> n >> k;
  int a[n];
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (i = 0; i < n; i++) {
    s += min(8, a[i] + carry);
    if (s >= k) {
      cout << i + 1 << '\n';
      break;
    }
    if (a[i] + carry > 8) {
      carry = carry + a[i] - 8;
    } else {
      carry = 0;
    }
  }
  if (i == n) {
    cout << -1 << '\n';
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
