// Try Codeforces
// author: Leonardone @ NEETSDKASU
import std.stdio, std.string, std.conv, std.algorithm;

T[] getVals(T)() { return to!(T[])(readln().chomp().split(" ")); }

void main() {
    auto nk = getVals!(int)();
    auto n = nk[0], k = nk[1];
    auto xs = getVals!(int)();
    auto candies = 0, present = 0;
    foreach (i, v; xs) {
        candies += v;
        present = min(candies, 8);
        candies -= present;
        k -= present;
        if (k <= 0) {
            writeln(i+1);
            return;
        }
    }
    writeln(-1);
}