#include <bits/stdc++.h>
using namespace std;
int a[105];
const int MAX = 8;
int main() {
  int candies = 0;
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  for (int i = 1; i <= n; ++i) {
    candies += a[i];
    k -= min(candies, MAX);
    if (candies < MAX)
      candies = 0;
    else
      candies -= MAX;
    if (k <= 0) {
      cout << i;
      return 0;
    }
  }
  cout << -1;
  return 0;
}
