Design 5 bit counter with two control inputs (direction and stop)
The simplest way would be to use an integrated chip that does the whole up/down counting. There are some specialized for this, for example the 74HC191.

If you use this specific chip, the input are a bit different than what you need:
you have the \$\overline{CTEN}\$ pin which can serve as a STOP input (if it is 1, the count is inhibited), and the \$D/\overline{U}\$ input, which of course works the other way around from what you require. So if you can't change the specs of your D and S inputs, you need a bit of logic to adapt it to this chip. An inverter gate from your D input could provide \$D/\overline{U}\$, and if you do a XOR between your D and S inputs, you obtain \$\overline{CTEN}\$. Note: you can implement the inverter with a XOR gate, as well, if you hardwire a 1 to one of its input. So you can have a single chip that does the two operations.

Now, the chip I mentioned is only a 4-bit counter. But you can chain them. Just use two such chips and connect the \$\overline{CTEN}\$ input of the second counter to the \$\overline{RCO}\$ output of the first, and tie the clocks of both chips together, and the D/U pin of both chips together (see figure 2 of the datasheet). Now, you even have an 8-bit counter !

In short, you can implement this with three chips.

... Of course, using a small microcontroller for all that would actually be cheaper and more effective. And this would also certainly allow you to simplify other parts of the whole circuit...