#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  int has = 0;
  int a;
  for (int i = 0; i < n; i++) {
    cin >> a;
    has += a;
    int give = min(has, 8);
    has -= give;
    k -= give;
    if (k <= 0) {
      cout << i + 1;
      return 0;
    }
  }
  cout << -1;
}
