#include <bits/stdc++.h>
using namespace std;
long min(long a, long b) { return a > b ? b : a; }
long max(long a, long b) { return a < b ? b : a; }
int main() {
  long n, k, s = 0;
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    long j;
    cin >> j;
    s += j;
    k -= min(s, 8);
    if (k <= 0) {
      cout << (i + 1) << endl;
      return 0;
    }
    s = max(s - 8, 0);
  }
  cout << -1 << endl;
  return 0;
}
