In the MAC protocol of 802.11, truncated binary exponential backoff (BEB) is used to resolve contention. The operation of BEB at an individual node can be modelled as a Markov chain, where each state represents the backoff state of a node. In backoff state $i$, $i = 0, 1, 2, 3, \dots, M$, the contention window size $W_i$ for a node is given by
$$
W_i = \begin{cases}
2^i W & 0 \le i < r, \\
2^r W & r \le i \le M,
\end{cases}
$$
where $W$ is the initial window size, and $M$ is the maximum allowed retries per packet and after reaching state $M$, a node goes to state 0 with a new packet even if the transmission was unsuccessful. At state $i$, the number of backoff slots is uniformly chosen from $[0, W_i - 1]$. Derive an expression for the average number of backoff slots of a successful packet transmission.