a = (((x + y + 1))^5)

Expand[a]

Collect[a, x]

Expand[a, Modulus -> 5]