Ajax finished in third spot in Group D and a place in the Europa League despite losing 4-1 to Real Madrid.