You may like to denote the red beads by 0 and the blue beads by 1. Then the new bead is given by the sum modulo 2 of the two adjacent beads because two the same colour are given by 0+0=0 and 1+1=0 and two different colours are given by 1+0=1 and 0+1=1.