The integers from $1$ to $2022$ are written on cards placed in a row on a table. Each number appears only once and each card shows exactly one number. Esmeralda performs consecutively the following operations $1011$ times: • She chooses a card on the table and puts it in a box on her right. • Right after it, she picks the leftmost card on the table and puts it in a box on her left. At the end of the process, she calculates the sum of the numbers in the left box. For each initial configuration $P$ of the cards, let $S(P)$ be the maximum sum Esmeralda can achieve. Determine the number of initial configurations $P$ for which $S(P)$ achieves its least value.