import std.stdio;
import std.string;
import std.algorithm;
import std.conv;
import std.array;
import std.range;
import std.math;

int main(string[] argv)
{
	auto gunVeSekerCifti = stdin.readln.chomp.split.map!( to!int );
	int gunSayisi = gunVeSekerCifti[0];
	size_t sekerTalebi = gunVeSekerCifti[1];
	int[] sekerKutulariDizisi = stdin.readln.chomp.split.map!( to!int ).array();
	
	int toplamSekerSayisi = reduce!((a,b) => a + b)(0, sekerKutulariDizisi);
	int maksimumSekerVerebilmeLimiti = gunSayisi * 8;

	if (sekerTalebi > maksimumSekerVerebilmeLimiti || sekerTalebi > toplamSekerSayisi   )
	{
		writeln(-1);
		return 0;
	} 


    size_t toplam = 0;
	for ( int i = 0; i < gunSayisi; i++ )
	{
		size_t deger = sekerKutulariDizisi[i];
		//deger > 8 ? toplam += 8 : toplam += deger ;
		size_t geciciDeger = deger;
		if ( deger > 8 ) 
			geciciDeger = 8;
			
		toplam += geciciDeger ;
		if ( toplam >= sekerTalebi )
		{	
			writeln( i + 1 ); 
			return 0;
		} 
		else
		{
			if ( deger > 8  ) 
				sekerKutulariDizisi[i + 1]	 +=  deger - 8;
		}

	}
	writeln(-1);
	return 0;
}
