Without loss of generality, assume $n \leq m$. Such a colour code ordering is just a sequence of alternating $R$ and $B$ letters. There are four types of such sequences, depending which letter they start and end with. Say a sequence is of type $(X,Y)$ if it begins with $X$ and ends with $Y$.
So, there are
- $n$ sequences of type $(R,B)$
- $n$ sequences of type $(B,R)$
- $n-1$ sequences of type $(R,R)$
- $n$ sequences of type $(B,B)$ (and only $n-1$ of them if $n=m$).
Thus, the answer is $4n-1$ if $n < m$, and $4n-2$ if $n=m$.