Artificial intelligent assistant

Combinatorics, dividing objects into groups. Assuming we have got 5 horses, that are competing in a race, and assuming 2 different horses can arrive at the exact same time. How many possibilities there are for outcomes? for 3 horses for example : 1st place:horse1 horse1 horse2 horse2 horse3 horse3 2nd place:horse2 horse3 horse1 horse3 horse2 horse1 3rd place:horse3 horse2 horse3 horse1 horse1 horse2 1st place : {horse1 horse2}{horse2 horse3}{horse3 horse1} 2nd place : {horse3} {horse1} {horse2} 1st place : {horse1} {horse2} {horse3} 2nd place: {horse2 horse3}{horse1 horse3}{horse1 horse2} 1st place :{horse1}{horse2}{horse3} So all in all 13 possibilities for 3 horses. my question is : how many for 5 horses?

If there are $n$ horses, the number of ways would be the sum of $k! \cdot S(n,k)$ for $1 \le k \le n$ where $S(n,k)$ is the Sterling number of the second kind, see here. For $5$ horses this gives $541$ ways.

Note that $S(n,k)$ counts the number of partitions of the $n$ horses into $k$ unlabeled sets, so must be multiplied by $k!$ because we want to consider which horses are in which place in the race.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 5a5169e5b5c91f806a2a55ffa005156a