4. We consider rows of 2020 coins. Each coin has a value of 1, 2, or 3. Between two coins with value 1, there is always at least one other coin. Between two coins with value 2, there are always at least two other coins. Between two coins with value 3, there are always at least three other coins.

How many different rows are there that meet these conditions?
B4. 10 Consider a continuous segment where no coin of value 3 is present. In this segment, there can be at most one coin of value 2, because otherwise we would have two coins of value 2 with only coins of value 1 in between, which is not allowed. Since there can be at most one coin of value 2, there can also be at most two coins of value 1, because otherwise we would have two coins of value 1 next to each other. The only possibilities for such a segment without coins of value 3 are thus

$$
121,12,21,2,1
$$

A row of 2020 coins must therefore have multiple coins of value 3. Consider in a row two coins of value 3 where no other coin of value 3 lies between them. Between these two coins, there must be at least three other coins. We have just seen that we then have exactly three coins, and 121 is the only possibility.

Our row of 2020 coins thus looks like this:

beginning segment- $\underbrace{312131213 \cdots \cdots 31213}_{\text {number of times the same pattern }}$-end segment,

where the beginning and end segments contain only coins of value 1 and 2. The only possibilities for the beginning and end segments are: $121,12,21,2,1$, or no coins.

The length of the repeating segment is a multiple of four plus one. The length of this segment must be less than $505 \cdot 4+1=2021$ and more than $503 \cdot 4+1=2013$, because otherwise the beginning and end segments together would have more than 6 coins. The length of the middle segment is thus equal to $504 \cdot 4+1=2017$ and the beginning and end segments together have $2020-2017=3$ coins. For the beginning and end segments, there are now 10 possibilities: nothing at the beginning and 121 at the end or vice versa (2 possibilities in total); 1 or 2 at the beginning and 12 or 21 at the end ($2 \cdot 2=4$ possibilities); 12 or 21 at the beginning and 1 or 2 at the end ($2 \cdot 2=4$ possibilities).