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