Decompose the event $\{\delta(X) \neq Y\}$ according to the value of $Y$:
\begin{align*}
Q(\delta(X) \neq Y) &= Q(Y = 1 \text{ and } \delta(X) \neq 1) + Q(Y = 0 \text{ and } \delta(X) \neq 0) \\
&= \pi_1 P_1(X \notin R) + \pi_0 P_0(X \in R) = R_\pi(\delta).
\end{align*}
The first equality separates the two types of error (labeling a class-1 observation as class 0, and a class-0 observation as class 1). The second uses the definition of $Q(x,y) = f_y(x)\pi(y)$ to factor the joint probability into the prior weight times the probability of misclassification under each class distribution.