#include <bits/stdc++.h>
using namespace std;
long long n, m, i, cl, k, l, x;
int main() {
  cin >> n >> m;
  for (i = 1; i <= n; i++) {
    cin >> x;
    k += x;
    if (k > 7) {
      k -= 8;
      l++;
      cl += 8;
      if (cl >= m) break;
    } else {
      l++;
      cl += k;
      k = 0;
      if (cl >= m) break;
    }
  }
  if (m > cl)
    cout << -1;
  else
    cout << l;
  return 0;
}
