4. Once, a team of Knights and a team of Liars met in the park and decided to ride the circular carousel, which can accommodate 40 people (the "Chain" carousel, where everyone sits one behind the other). When they sat down, each person saw two others, one in front of them and one behind them, and said: "At least one of the people sitting in front of me or behind me belongs to my team." One seat remained empty, and they invited another Liar. This Liar said: "Together with me, we can arrange ourselves on the carousel so that this rule is satisfied again." How many people were in the team of Knights? (A Knight always tells the truth, a Liar always lies.)
Solution. Let's consider the initial seating arrangement. From the statement of each Liar, it follows that none of those sitting in front of or behind him is a Liar, i.e., each Liar is surrounded by two Knights. Knights and Liars cannot alternate, as in front of or behind each Knight, there must be at least one Knight. Therefore, Liars and Knights in the seating arrangement form sequences ...KKLKKLKK... Between two Knights, whose neighbors are Liars, any number of Knights can be added in the initial seating, for example, ...KKLKKKKKKLKK... Therefore, the minimum number of Knights will only be in the case where the seating is in triplets ...KKLKK.L... Initially, 39 seats are occupied, this number is divisible by 3, so the maximum number of Liars is 13, and the minimum number of Knights is 26. Note that if one Liar is replaced by a Knight, then we get 12 Liars, for the formation of triplets, 24 Knights are needed, and 3 more Knights can be placed arbitrarily between other Knights.

The problem states that the seating is redone when another Liar appears. Let's see how 40 people, including the additional Liar, can be seated. From his statement, it follows that it is impossible to seat them so that at least one of those sitting in front of or behind each belongs to his team. If we had an extra triplet of Knights, which we placed freely during the first seating, then the additional Liar together with two of them could form a triplet ..KKL.. Therefore, there could not have been more than 26 Knights in the initial seating.

Answer. The team of Knights consisted of 26 people.