#include <bits/stdc++.h>
using namespace std;
int n, k;
inline void solve() {
  cin >> n >> k;
  vector<int> a(n);
  for (long long i = 0; i < (n); ++i) {
    cin >> a[i];
  }
  int ans = -1, arya = 0, i = 0;
  while (i < n) {
    arya += a[i];
    if (k - 8 <= 0 && arya >= k) {
      ans = i + 1;
      break;
    }
    if (arya >= 8) {
      k -= 8;
      arya -= 8;
    } else {
      k -= arya;
      arya = 0;
    }
    i++;
  }
  cout << ans << endl;
}
int main() { solve(); }
