#include <bits/stdc++.h>
using namespace std;
bool comp(int a, int b) { return (a > b); }
int main() {
  int n, k;
  cin >> n >> k;
  int arr[n];
  int ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  int sum = 0;
  for (int i = 0; i < n; i++) {
    if (arr[i] > 8) {
      sum += 8;
      if (i != n - 1) arr[i + 1] += arr[i] - 8;
      ans++;
    } else {
      sum += arr[i];
      ans++;
    }
    if (sum >= k) {
      cout << ans << "\n";
      return 0;
    }
  }
  cout << "-1\n";
  return 0;
}
