#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, t, i, b;
  cin >> n >> k;
  bool p = false;
  t = i = 0;
  while (n--) {
    cin >> b;
    t += b;
    k -= min(8, t);
    t -= min(8, t);
    i++;
    if (k <= 0) {
      p = true;
      break;
    }
  }
  cout << (p ? i : -1) << endl;
}
