#include <bits/stdc++.h>
using namespace std;
int cnt;
int g[111][111];
int cnt1[10000];
bool used[30000];
int main() {
  int n, m;
  cin >> n >> m;
  int a[100010];
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  int s = 0, left = 0;
  bool found = false;
  int i = 0;
  for (i = 1; i <= n; i++) {
    int f = a[i] + left;
    if (f > 8) {
      left = f - 8;
      s += 8;
    } else {
      s += f;
      left = 0;
    }
    if (s >= m) {
      found = true;
      break;
    }
  }
  if (found)
    cout << i << endl;
  else
    cout << -1 << endl;
  return 0;
}
