#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int m, long long int n) {
  if (n == 0) return m;
  return gcd(n, m % n);
}
int MOD = 1000000000;
long long int powmod(long long int a, long long int b) {
  if (b == 0) return 1;
  long long int x = powmod(a, b / 2);
  long long int y = (x * x) % MOD;
  if (b % 2) return (a * y) % MOD;
  return y % MOD;
}
int main() {
  std::ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  int z;
  int a[10000];
  for (int i = 0; i < n; i++) cin >> a[i];
  int ans = 0;
  for (int i = 0; i < n - 1; i++) {
    if (a[i] > 8) {
      a[i + 1] = a[i + 1] + a[i] - 8;
      k = k - 8;
    } else
      k = k - a[i];
    if (k <= 0) {
      cout << i + 1 << endl;
      return 0;
    }
  }
  if (k - min(a[n - 1], 8) > 0)
    cout << "-1" << endl;
  else
    cout << n << endl;
  return 0;
}
