I think 9 races.
The races are conducted in 3 rounds. The first round, the horses are divided up into 5 groups of 5 horses. Each group runs a race, making 5 races in this round.
The second round has 3 races. All of the first-place horses from each of the first-round races run against each other, all of the second-place horses run against each other, and all of the third-place horses run against each other. The fourth- and fifth-place horses are eliminated.
The horse that comes in first out of all the first-place horse is the fastest overall, and need not run in another race.
Out of the horses that came in first place in the first round, the ones that came in second and third in the next round go on to the final round. The fourth- and fith-place horses are again eliminated.
Out of the horses that came in second in the first round, the ones that came in first and second in the next round go on to the finals. The third place is eliminated because that horse had been beaten by 3 other horses already: one in the first round and 2 other horses in the second. Fourth- and fifth-place are eliminated, as before.
Finally, out of the horses that came third in the first round, only the horse that came first in the second round goes on to the finals. The other horses were already outrun by 2 horses in the first round, and 1 or 2 horses in the second round. Fourth- and fifth-place are eliminated, as before.
Thus, the horses that run in the final race are the second and third place out of the first-placers, the first and second out of the second-placers, and the first out of the third-placers. The winner and runner-up from this round are the second and third ranked overall, joining the winner of the first-placers’ race in the top 3.
So, there are 5 races in the first round, 3 race in the second, and one final race, making 9 in total.