#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long bigmod(long long a, long long b) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = (ans * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return ans;
}
inline void sc(int &n) {
  n = 0;
  int c = getchar();
  int f = 1;
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    n = (n << 3) + (n << 1) + c - '0', c = getchar();
  }
  n = n * f;
}
using namespace std;
int main() {
  long long n, k;
  cin >> n >> k;
  long long a[n + 1];
  for (int i = 0; i < n; i++) cin >> a[i];
  long long total = 0, x;
  for (int i = 0; i < n; i++) {
    x = (a[i] >= 8 ? 8 : a[i]);
    total += x;
    a[i] -= x;
    if (total >= k) return cout << i + 1 << endl, 0;
    a[i + 1] += a[i];
  }
  cout << "-1" << endl;
}
