#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3f;
const long long mod = 1e9 + 7;
const double PI = acos(-1.0);
const double eps = 1e-10;
int n, m, k, a;
int main() {
  scanf("%d %d", &n, &k);
  int num = m = 0;
  bool first = true;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a);
    m += a;
    int give = min(k, min(m, 8));
    k -= give, m -= give;
    if (k <= 0 && first) num = i + 1, first = false;
  }
  printf("%d\n", k ? -1 : num);
  return 0;
}
