A high abundance of massive galaxies 3–6 billion years after the Big Bang