#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, k, ret = 0, x, cur = 0;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> x;
    cur += x;
    int t = min(cur, 8);
    k -= t;
    cur -= t;
    ret++;
    if (k <= 0) {
      cout << ret << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}
