CMIMC 2022 Algebra and Number Theory Division 1 Problem 6

Find the probability such that when a polynomial in \mathbb{Z}_{2027}[x] having degree at most 2026 is chosen uniformly at random,

x^{2027}-x\left|P^{k}(x)-x \Longleftrightarrow 2021\right| k

(note that 2027 is prime).

Here P^{k}(x) denotes P composed with itself k times.