31. There are 12 pairs of gloves (all gloves are for either the left or right hand) in a bag, among which 5 pairs are red, 4 pairs are blue, and 3 pairs are white. Xiaoxin cannot see the colors of the gloves in the bag, but he can put his hand into the bag to try them on and determine the left or right hand, taking out one glove at a time. Xiaoxin must take out at least $\qquad$ gloves to ensure that he has a pair of the same color.
$9$