#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000000;
int num[1000000];
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) scanf("%d", &num[i]);
  int sum = 0;
  int ans = 0;
  int cnt = -1;
  for (int i = 0; i < n; i++) {
    sum += num[i];
    if (sum >= 8) {
      ans += 8;
      sum -= 8;
    } else {
      ans += sum;
      sum = 0;
    }
    if (ans >= k) {
      cnt = i + 1;
      break;
    }
  }
  cout << cnt << endl;
  return 0;
}
