#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, tot = 0, a[105];
  cin >> n >> k;
  for (int i = 0; i < n; ++i) cin >> a[i];
  int ans;
  for (ans = 0; ans < n; ++ans) {
    if (a[ans] <= 8) {
      int temp = min(8 - a[ans], tot);
      k -= a[ans] + temp;
      tot -= temp;
    } else {
      k -= 8;
      tot += a[ans] - 8;
    }
    if (k <= 0) break;
  }
  if (k > 0) ans = -2;
  cout << ans + 1 << endl;
  return 0;
}
