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 1. $n$ sequences of type $(R,B)$ 2. $n$ sequences of type $(B,R)$ 3. $n-1$ sequences of type $(R,R)$ 4. $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$.