#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0);
  long long n;
  long long k;
  cin >> n;
  cin >> k;
  int count = 0;
  long long a[n];
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (long long i = 0; i < n && k > 0; i++) {
    if (a[i] <= 8) {
      count++;
      k -= a[i];
    } else {
      k -= 8;
      a[i] = a[i] - 8;
      if (i + 1 < n) {
        a[i + 1] += a[i];
      }
      count++;
    }
  }
  if (k > 0)
    cout << -1;
  else
    cout << count;
}
