#include <bits/stdc++.h>
using namespace std;
inline void invi(vector<int> &a) {
  for (int i = 0; i < a.size(); i++) scanf("%d", &a[i]);
}
inline void outvi(vector<int> &a) {
  for (int i = 0; i < a.size(); i++) printf("%d ", a[i]);
  printf("\n");
}
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  invi(a);
  int sum = 0;
  for (auto in : a) sum += in;
  if (sum < k) {
    printf("-1");
    return 0;
  }
  int buffer = 0, days = 1;
  for (size_t i = 0; i < n; i++, days++) {
    buffer += a[i];
    if (buffer > 8)
      buffer -= 8, k -= 8;
    else
      k -= buffer, buffer = 0;
    if (k <= 0) {
      cout << days;
      return 0;
    }
  }
  cout << -1;
}
