#include <bits/stdc++.h>
using namespace std;
long long a[100000];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> a[i];
  long long s = 0;
  long long t1, t2;
  bool ans1 = false;
  long long ans;
  for (int i = 0; i < n; i++) {
    s += a[i];
    t1 = s;
    t2 = k;
    if (k < 8) {
      k -= min(t1, t2);
      s -= min(t1, t2);
    } else {
      s -= min((long long)8, t1);
      k -= min((long long)8, t1);
    }
    if (k == 0) {
      ans1 = true;
      ans = i + 1;
      break;
    }
  }
  if (ans1)
    cout << ans << endl;
  else
    cout << "-1" << endl;
  return 0;
}
