Fixed formula for finding biggest possible k
New structure, removed all that is not going to be included.