6. A group of little monkeys and little bears line up in a single file, with each little bear only adjacent to little monkeys, and no more than 3 little monkeys can be lined up together. Little monkey QiQi has 6 little bears in front of it, and 3 little bears behind it. The maximum number of little monkeys and little bears in the queue is $\qquad$.

将上面的文本翻译成英文，请保留源文本的换行和格式，直接输出翻译结果。
$39$