#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
const int MOD = 1e9 + 7;
int main() {
  int n, k;
  cin >> n >> k;
  int cnt = 0;
  int tmp = 0;
  int tmp2 = 0;
  for (int i = 1; i <= n; i++) {
    int a;
    cin >> a;
    if (a + tmp > 8)
      tmp2 += 8, tmp = a + tmp - 8;
    else
      tmp2 += (a + tmp), tmp = 0;
    if (tmp2 < k) cnt++;
  }
  if (tmp2 < k)
    cout << -1 << endl;
  else
    cout << cnt + 1 << endl;
  return 0;
}
