#include <bits/stdc++.h>
using namespace std;
long long n, k, sum, num, maxi = -10e9, maxn = -10e9, mini = 10e9, minn = 10e9,
                          a[101];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie();
  cout.tie();
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; i++) {
    if (a[i] <= 8) {
      sum += a[i];
      if (num > 8 - a[i]) {
        sum += 8 - a[i];
        num -= 8 - a[i];
      } else {
        sum += num;
        num = 0;
      }
    } else {
      num += a[i] - 8;
      sum += 8;
    }
    if (sum >= k) {
      cout << i;
      return 0;
    }
  }
  cout << -1;
  return 0;
}
