#include <bits/stdc++.h>
using namespace std;
int n, k;
int a[103], cur, ans = -1;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  for (int i = (int)1; i <= (int)n; i++) {
    int x;
    cin >> x;
    cur += x;
    int p = min(cur, 8);
    cur -= p;
    k -= p;
    if (k <= 0) {
      ans = i;
      break;
    }
  }
  cout << ans << "\n";
  return 0;
}
